Reputation: 457
I have a string "abc"
, and I want to search, in a SQL table, for the values that contain either a, b or c.
This is what I have right now:
Select * from TABLE where NAME like "abc" ;
This didn't work, but I know if I try something like
where Name like "a" or Name like "b" or ....
it will work.
Is there an easier way to do this? Since I don't want to separate my string into characters.
Upvotes: 0
Views: 88
Reputation: 8652
You can use regular expression for this.
Have a look at the following :
Select * from TABLE where NAME REGEXP "[abc]";
Upvotes: 2
Reputation: 875
This will do
Select * from TABLE where NAME like "%abc%" ;
For more check information here http://www.techonthenet.com/sql/like.php
Upvotes: -2