如何搜索table_a table_b table_c
,其中包含一个字符串的随机列数?
我知道这不是正确的sql但它会是这样的:
SELECT * FROM users, accounts, something_else WHERE ->ANY COLUMN CONTAINS 'this_string'<-
提前为SO社区提供
答案 0 :(得分:29)
将fulltext indexes添加到所有这些表中的所有字符串列,然后将结果联合起来
select * from table1 where match(col1, col2, col3) against ('some string')
union all
select * from table2 where match(col1, col2) against ('some string')
union all
select * from table3 where match(col1, col2, col3, col4) against ('some string')
...