【发布时间】:2011-07-28 18:55:57
【问题描述】:
可能的重复:
MYSQL query for searching through ALL the fields?
MySQL - Search in all fields from every table from a database
我在一个表中有 28 个字段,我想为用户提供的一个选项是搜索其所有字段中的每个条目。 所以不要写这样的东西:
SELECT * FROM table WHERE field1 LIKE testfield OR field2 LIKE testfield OR field3 LIKE testfield
OR field4 LIKE testfield OR ... etc
我想写这样的东西:
SELECT * FROM table WHERE * LIKE testfield;
这不起作用,所以我想知道是否有其他语法或该功能不存在?
【问题讨论】:
-
同一个问题stackoverflow.com/questions/3797906/… 链接到另一个类似问题...
-
SpyrosP 所链接的问题在两者中具有更好的答案。
标签: mysql