开发者

Wildcard in the IN clause

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 solu开发者_开发技巧tion should be with the IN clause.


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'


I guess what you're looking for is not an IN Condition, but an LIKE Condition. What about searching for

SELECT DISTINCT ID, FROM INST WHERE TYPE like 'IP_%_International'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜