开发者

How to write "WHERE foo = 'bar' OR foo = 'baz' OR ..." without repeating "foo" each time

I'm new to MySQL and was wondering; instead of doing

SELECT fields FROM table WHERE name="tim" OR name="bob" OR name="nancy" OR name="john"

If I could do something like

SELECT fields FROM table WHERE (name="tim" OR "bob" OR "nancy" OR "john开发者_开发问答")


Use the IN clause:

SELECT fields FROM table WHERE name IN ("tim", "bob", "nancy", "john");


You can do like -

SELECT fields FROM table WHERE name in("tim","bob","nancy","john")
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜