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


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 = '格力' )


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM