Click to See Complete Forum and Search --> : LIKE statement
remcoploeg
August 27th, 2001, 06:27 AM
I want to make a LIKE statement with a variable, when I do it like this, it doesn't work:
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE ''" & searchrel
What is the right statement with a variable??
Remco Ploeg
ploegr@promar-agencies.nl
Cimperiali
August 27th, 2001, 06:34 AM
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE " & searchrel
or
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE '%" & searchrel & "%'"
or
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE ''%" & searchrel & "%''"
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
The Rater
remcoploeg
August 27th, 2001, 06:44 AM
this is working, but now he shows the records that contains the variable. For example
variable = k
kampa company
esko company
He display the two record because there is a k in. I want only the first letter
Remco Ploeg
ploegr@promar-agencies.nl
Cakkie
August 27th, 2001, 07:13 AM
This should do the trick
tSQL = "Select * from klantenbestand WHERE Company_Name LIKE '" & searchrel & "%'"
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.