我想在表catalog_form
中的多个字段中进行搜索。使用Concat和LIKES(我使用foreach
进行循环)
我想念什么?感谢您的所有帮助。
SELECT *
FROM catalog_form
WHERE CONCAT(image, acc_no, cat_no, art_type, title, mat_tech
, acquired_by, dimensions, maker_pub, place_origin
, location, description, encoded_by) LIKE '%maria%'
OR LIKE '%great%'
ORDER BY id DESC LIMIT 0, 10
答案 0 :(得分:0)
您应该为OR子句重复concat值
SELECT *
FROM catalog_form
WHERE CONCAT(image, acc_no, cat_no, art_type, title, mat_tech
, acquired_by, dimensions, maker_pub, place_origin
, location, description, encoded_by) LIKE '%maria%'
OR
CONCAT(image, acc_no, cat_no, art_type, title, mat_tech
, acquired_by, dimensions, maker_pub, place_origin
, location, description, encoded_by)
LIKE '%great%'
ORDER BY id DESC LIMIT 0, 10
答案 1 :(得分:0)
我能够解决这个问题,我将整个CONCAT放在了第二个LIKE之前。谢谢您的宝贵时间!!