Link to home
Start Free TrialLog in
Avatar of iven
iven

asked on

sql ('LIKE')statement

Hi,this is my problem.i want to delete the whole record that the BN start with ABC,when i test this sql in MS Access it works:

DELETE FROM Employee
WHERE BN Like "ABC*"

example:    BN
          ABC123
          ABC456

but error appear when i run it on VB.i try many way to replace the string of "ABC*" but failed.

sql = " SELECT * FROM Employee " & _
       "WHERE BN LIKE '" & ABC* & "' " <<syntax error

sql = " SELECT * FROM Employee " & _
       "WHERE BN LIKE '" & ABC% & "' " <<nothing selected

thanks!
Avatar of Chandramouli k
Chandramouli k
Flag of India image

ur first sql should work. any way try replacing double quotes with single as follows.

Delete * from Employee where bn like 'ABC*'


KCM
Avatar of Ryan Chong
Hi iven,

Try this instead:

sql = " SELECT * FROM Employee " & _
      "WHERE BN LIKE '" & ABC & "%' "

Cheers
so, that's:

DELETE FROM Employee
WHERE BN Like "ABC%"
to: ryancys
It is not working in my sys.
mins is MS-Access2k.

kcm

ASKER CERTIFIED SOLUTION
Avatar of KarcOrigin
KarcOrigin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
looks list quotes problem:

sql = " SELECT * FROM Employee " & _
      "WHERE BN LIKE 'ABC%' " 
Iven u there.?
kcm76, Use "%" in VB, use "*" when debuging in M$ Access..
Avatar of iven
iven

ASKER

THANKS!!!!!u r so great!

also thanks every one that answer the question to me.