|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
WHERE xxx IN() with wildcard?
Hello everyone,
is there a way to use wildcards in a WHERE IN() clause? i.e. SELECT * FROM foo WHERE bar IN ('value%','wert%')) Thanks! thomas |
|
#2
|
|||
|
|||
|
Do you have to use IN ...? Why not WHERE bar LIKE 'value%' OR bar LIKE 'wert%'?
__________________
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer" - Bruce Graham |
|
#3
|
|||
|
|||
|
Yeah, otherwise the queries would turn out to be miles long. I tried my luck with REGEXP now and it seems to work fine ...
|
|
#4
|
|||
|
|||
|
Would you mind sharing the solution?
__________________
What you get is either what you desired or what you deserved. Death seems to be such an abominable thing, but do we really want to live for ever? |
|
#5
|
|||
|
|||
|
Sure.
SELECT * FROM foo WHERE bar REGEXP 'value[[:alpha:]]|wert[[:alpha:]]' [[:alpha:]] is for any alphanumeric combination and | is OR. |
|
#6
|
|||
|
|||
|
Thank you.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > WHERE xxx IN() with wildcard? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|