select parttime_job_business_assessments.*, u.nick_name, u.mobile, pj.name as job_name, b.name as business_name from `parttime_job_business_assessments`
left join `users` as `u` on `u`.`id` = `parttime_job_business_assessments`.`user_id`
left join `parttime_jobs` as `pj` on `pj`.`id` = `parttime_job_business_assessments`.`job_id`
left join `businesses` as `b` on `b`.`id` = `parttime_job_business_assessments`.`business_id`
where 1 = 1
AND concat(pj.`name`, u.`nick_name`,u.`mobile`,b.`name`) LIKE "%郝%"
order by `parttime_job_business_assessments`.`sort_id` desc
limit 10 offset 0
————————————————
版权声明:本文为CSDN博主「Yietion」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u010496966/article/details/83818268
当搜索某一关键词的时候,要查询多个表的字段是否包含该关键字,这个时候可以使用:
concat(表1.字段1, 表二.字段二......) LIKE "%关键词%"
上例为查询“郝“关键词,可以是users表的nick_name和mobile字段,也可以是parttime_jobs表的name字段,同时还可以是businesses的name字段
————————————————
版权声明:本文为CSDN博主「Yietion」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u010496966/article/details/83818268
原文地址:https://www.cnblogs.com/gaogaoxingxing/p/12401996.html