mysql数据库如何搜索关键词

2025-02-12 07:14:40
推荐回答(4个)
回答(1):

办法如下:

select * from table1 where concat(`字段`,`字段`,`字段` ) like '%关键字%' union
select * from table2 where concat(`字段`,`字段`,`字段` ) like '%关键字%' union
select * from table3 where concat(`字段`,`字段`,`字段` ) like '%关键字%' union
select * from table4 where concat(`字段`,`字段`,`字段` ) like '%关键字%' union
select * from table5 where concat(`字段`,`字段`,`字段` ) like '%关键字%' 
前提是查询出来的字段个数要一样,类型要对应好,至于如何得到正确且符合你需要的sql就要在程序类中处理了。

回答(2):

select * from table1 where 列名1 like ‘%77%'

回答(3):

select 列名 from table1 where 列名 like ‘%77%’

回答(4):

select * from table1 where 列名1 like ‘%77%' or 列名2 like ‘%77%'。。。。。。。。。。。。。。。。