Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Jul 16, 1999

Designing a keyord search query in Access

Question:
I'm still quite new to using SQL and I am designing a database in which I am cataloging resources owned by my company. I am attempting to create a query that will allow the user to enter a value such as an author's name and have the query search the author's field to provide all records with that author's name. My problem is that when I set a parameter and run the query, the prompt shows up and requests that the user enter the parameter. This part is fine, however, it only works if the parameter value is exactly what was entered by the user. For example if the Authors name is John Smith, but at the prompt the user enters only Smith, no records appear. I am designing in Access.

Answer:
It sounds to me like you need the LIKE comparison operator with a "%" (percent sign) on both sides of the thing you want to test like this:


SELECT framis
FROM foobar
WHERE foobar.framis LIKE %SMITH% 
This will retrieve Smithson, Winesmith and Smith.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date