Jump to content

Problem with Select and using wildcard characters


snpcrd

Recommended Posts

Hi,Having a problem selecting records from an Access 2003 database. With the below SQL from what I understand it should select all records in the database based on using the wildcard character '%'.

SELECT * FROM Unsnooped WHERE RegionCode LIKE '%' AND ClinicGroup LIKE '%' AND Snooped LIKE '%' ORDER BY Sitecode ASC 

Example DB records can be found at accessdb.gif. The rightmost field is the one called 'Snooped'. There are 1033 records in the DB but it will only display 496. All the fields that I'm trying to pull out are populated by values so I'm a bit of a loss.Cheers

Link to comment
Share on other sites

Hi,Having a problem selecting records from an Access 2003 database. With the below SQL from what I understand it should select all records in the database based on using the wildcard character '%'.
SELECT * FROM Unsnooped WHERE RegionCode LIKE '%' AND ClinicGroup LIKE '%' AND Snooped LIKE '%' ORDER BY Sitecode ASC 

The WHERE clause is superfluous increases unnecessary overhead if you're trying to select all records. Do this instead:
SELECT * From Unsnooped ORDER BY Sitecode ASC

Example DB records can be found at accessdb.gif. The rightmost field is the one called 'Snooped'. There are 1033 records in the DB but it will only display 496. All the fields that I'm trying to pull out are populated by values so I'm a bit of a loss.
I don't use Access a lot, but I'm pretty sure your problem traces back to MS Access' handling of nulls. A null is not the same as an empty string, so if one of your RegionCode, ClinicGroup, or Snooped fields contains null data, it won't be returned in your dataset.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...