我如何将IN表与like一起使用?这样我就可以在其中使用%了?我的意思是:
SELECT fields FROM table WHERE age = "50" AND name IN ("tim", "bob", "nancy", "john");
我已经尝试过:
SELECT fields FROM table WHERE age = "50" AND name LIKE ("2010-09-17%", "2010-09-16%")
但是它给出了错误“操作数应包含1列”
您可以使用许多LIKE表达式:
SELECT fields FROM table WHERE age = "50" AND ( name LIKE "2010-09-17%" OR name LIKE "2010-09-16%" );
或者您可以使用正则表达式:
SELECT fields FROM table WHERE age = "50" AND name REGEXP "2010-09-17.*|2010-09-16.*";
或者,巧妙地
SELECT fields FROM table WHERE age = "50" AND name REGEXP "2010-09-1(6|7).*";