我有两张桌子。一个包含两个文本字段以及其他字段。另一个表包含varchar字段。我想使用LIKE%keyword%搜索这三个字段。当我只搜索文本字段或varchar字段时,它可以工作。当我尝试搜索所有三个时,只搜索varchar。这是sql
SELECT *
FROM modx_expertise e
INNER JOIN modx_expertise_appraiser ea ON e.expertise_id = ea.expertise_id
INNER JOIN modx_web_user_attributes ua ON ua.internalKey = ea.internalKey
INNER JOIN modx_web_user_attributes_extended uae ON uae.internalKey = ua.internalkey
WHERE uae.specialities
OR uae.bio
OR e.expertise
LIKE '%$keyword%'
GROUP BY fname, lname";
答案 0 :(得分:0)
SELECT *
FROM modx_expertise e
INNER JOIN modx_expertise_appraiser ea ON e.expertise_id = ea.expertise_id
INNER JOIN modx_web_user_attributes ua ON ua.internalKey = ea.internalKey
INNER JOIN modx_web_user_attributes_extended uae ON uae.internalKey = ua.internalkey
WHERE uae.specialities
LIKE '%$keyword%'
OR uae.bio
LIKE '%$keyword%'
OR e.expertise
LIKE '%$keyword%'
GROUP BY fname, lname";
答案 1 :(得分:0)
...
WHERE uae.specialities LIKE '%$keyword%'
OR uae.bio LIKE '%$keyword%'
OR e.expertise LIKE '%$keyword%'
...