此 SQL 工作正常:
SELECT * from table_name where id IN (473,473,475);
这不会:
SELECT * from table_name where id IN CONCAT('(', '473,473,475', ')');
它说:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'CONCAT('(', '473,473,475', ')')' at line 1
为什么?
我想像这样使用它:
SELECT * from table_name where id IN CONCAT('(', ids, ')');
ids 是 varchar 并包含如下内容:
473,473,475