Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using 'LIKE' operator in SQL statement

Status
Not open for further replies.

diamondsc

Programmer
Jun 28, 2001
44
US
I have tried to use the following sql statement in a VBA module:

sqlStr = "Select * From Medications Where MedName Like 'ZOCOR*';"

No records are returned. Will a Like operator not work in this situation? If not, what statement would work? Thanks.
 

It depends on your DBMS. The ANSI standard wild cards are "%" for "any string of characters" and "_" for "any single character"

Try
sqlStr = "Select * From Medications Where MedName Like 'ZOCOR%';"

 
Using MS Access 2000 VBA and retrieving data from MS SQL Server 2000. I've used the like operator like this in an If statement but have never tried it in a sql statement. The asterisk is suppose to be the wild card for any string of characters.
 
...[if] the prophet had bid thee [do some] great thing, wouldest thou not have done [it]? how much rather then, when he saith to thee,... (2nd Kings 5:13)

(In other words, have you tried my suggestion?)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top