Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard in the IN clause

Tags:

sql

SQL: I want use the wildcard "%" in the IN clause but I'm not getting the results I expect. My query is like this

SELECT DISTINCT ID,
              FROM INST
WHERE TYPE in ('IP_%_International')

Please help resolve this and the solution should be with the IN clause.

like image 740
Kavitha Avatar asked Feb 17 '11 09:02

Kavitha


1 Answers

You can't do that. IN is for literals, percent signs are for LIKE. Sorry! So WHERE type LIKE 'IP_%_International'. But if you have several patterns , the only thing you can do is to OR them together.WHERE type LIKE 'IP_%_International' OR type LIKE 'some_%_other_pattern'

like image 181
chx Avatar answered Oct 06 '22 01:10

chx