首页 > 数据库技术 > 详细

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

时间:2020-07-22 13:53:10      阅读:154      评论:0      收藏:0      [点我收藏+]

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 一个搜索框 匹配表中多个字段

原文:https://www.cnblogs.com/cscq168/p/13359749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!