gpt4 book ai didi

MySQL:如何在多个表中搜索任何列中存在的字符串

转载 作者:IT王子 更新时间:2023-10-28 23:45:51 28 4
gpt4 key购买 nike

如何在 table_a table_b table_c 中搜索具有随机列数的字符串?

我知道这不是正确的 sql,但它会是这样的:

SELECT * FROM users, accounts, something_else WHERE ->ANY COLUMN CONTAINS 'this_string'<-

提前为 SO 社区打个招呼

最佳答案

添加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')
...

关于MySQL:如何在多个表中搜索任何列中存在的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/394041/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com