当前位置:Gxlcms > 数据库问题 > mysql 一个搜索框 匹配表中多个字段

mysql 一个搜索框 匹配表中多个字段

时间:2021-07-01 10:21:17 帮助过:53人阅读

select * from table where id=1 and uid=2 and (status=2 or status=3 or status=4);

以下个人使用案例:多个字段,查询条件 格力

SELECT
a.sid,
a.spid,
a.sname,
a.spic,
a.sprice,
a.smarket,
a.ssn,
a.samount,
a.stime,
a.smarktime,
a.creationtime,
a.sinfo,
a.productmoney,
a.membermoney,
a.company,
a.specifications,
a.supplyStoreName,
c.bname AS sbrand,
b.NAME AS typeName
FROM
shop_goods a
LEFT JOIN sys_dictionary b ON a.spid = b.ID
LEFT JOIN shop_brand c ON a.sbrand = c.bid
WHERE
1 = 1
AND (a.sname LIKE CONCAT( CONCAT( ‘%‘, ‘格力‘ ), ‘%‘ ) or a.ssn =‘格力‘ or b.NAME =‘格力‘ or c.bname = ‘格力‘ )
技术图片

技术图片

mysql 一个搜索框 匹配表中多个字段

标签:uid   info   spec   cti   time   image   tps   and   格力   

人气教程排行