Computing.Net > Forums > Programming > MS Query - Parameters

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

MS Query - Parameters

Reply to Message Icon

Name: kaseyleigh
Date: August 16, 2006 at 10:14:31 Pacific
OS: Win 2003
CPU/Ram: 512
Product: Dell
Comment:

Hi

Is it possible to create a parameter to select multiple criteria, by using "Like" for retrieving data begininning with A, eg A* ??

Ta
Kasey



Sponsored Link
Ads by Google

Response Number 1
Name: siteforge (by Greg Apel)
Date: September 5, 2006 at 15:43:51 Pacific
Reply:

Hi Kasey,

This response might be a little late, but for the sake of this unanswered question, here goes:

Yes, you can use the wildcards to select specific data.

Using the LIKE condition, you can use two wildcards:

% allows you to match a string of any length
_ allows you to match a single character

ex.1
SELECT * FROM users WHERE lastname LIKE 'A%'

This would find all of the records in the users table with the lastname beginning with the letter A.

ex.2
SELECT * FROM users WHERE lastname LIKE '%son%'

This would find records where the lastname contains the letters 'son':
Johnson
Bissonnett
Simpson

ex.3
SELECT * FROM users WHERE firstname LIKE 'C_nd_'

Using the _ wildcard finds all firstname possibilities:
Candi
Candy
Cindi
Cindy
Condi

ex.4
SELECT * FROM users WHERE lastname NOT LIKE 'A%'

Returns all records EXCEPT for lastnames which begin with the letter 'A'

ex.5
SELECT * FROM users WHERE lastname LIKE 'A%' ORDER BY id ASC

Returns all lastnames beginning with letter 'A' and organizes them in ascending order (ASC) according to the unique id index, and aren't in alphabetical order.

ex.6
SELECT * FROM users WHERE lastname LIKE 'A%' ORDER BY lastname ASC

Again, returns all lastnames beginning with the letter 'A', yet they are organized in ascending order according to the lastname. This has the effect of alphabetizing them.

Using DESC would reverse the order, be it alpha or numeric, depending on the field you are using with the ORDER BY clause.


0

Response Number 2
Name: siteforge (by Greg Apel)
Date: September 5, 2006 at 15:48:08 Pacific
Reply:

One last thing:

The LIKE condition can be used in all SQL statements - SELECT, INSERT, UPDATE, DELETE


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


cpp builder Excel programming



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: MS Query - Parameters

MS Query - Parameters www.computing.net/answers/programming/ms-query-parameters/16408.html

SQL/Ms-Access Parameter Query www.computing.net/answers/programming/sqlmsaccess-parameter-query/10691.html

MS Access Parameter Queries www.computing.net/answers/programming/ms-access-parameter-queries/995.html