Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

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!
0
iven
Asked:
iven
1 Solution
 
Chandramouli kArchitectCommented:
ur first sql should work. any way try replacing double quotes with single as follows.

Delete * from Employee where bn like 'ABC*'


KCM
0
 
Ryan ChongCommented:
Hi iven,

Try this instead:

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

Cheers
0
 
Ryan ChongCommented:
so, that's:

DELETE FROM Employee
WHERE BN Like "ABC%"
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Chandramouli kArchitectCommented:
to: ryancys
It is not working in my sys.
mins is MS-Access2k.

kcm

0
 
KarcOriginCommented:
Hi iven,
Try this -

Select * From Employee
Where BN Like " & "'ABC%'"
0
 
Éric MoreauSenior .Net ConsultantCommented:
looks list quotes problem:

sql = " SELECT * FROM Employee " & _
      "WHERE BN LIKE 'ABC%' " 
0
 
Chandramouli kArchitectCommented:
Iven u there.?
0
 
Ryan ChongCommented:
kcm76, Use "%" in VB, use "*" when debuging in M$ Access..
0
 
ivenAuthor Commented:
THANKS!!!!!u r so great!

also thanks every one that answer the question to me.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now