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

时间:2020-07-22 16:02:21   收藏:0   阅读:87

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 = ‘格力‘ )
技术图片

技术图片

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!