0
我有一個查詢在兩個字段FIELD_IMPORTANT和FIELD_2中搜索「字符串」。在mySQL中使用WHERE子句並搜索兩列中的字符串
我想要結果;
如果「串」在FIELD_IMPORTANT發現再下訂單具有頂部, 在FIELD_IMPORTANT的「串」的記錄,然後其他人的結果...
這可能嗎?
到現在我有以下幾點:
SELECT
expert.expert_name, naf_add.FIELD_IMPORTANT, naf_level_5.FIELD_2,
ROUND(AVG(expert_rating.rating_global)) AS avg_rating_global
FROM naf_nomenclature
LEFT JOIN naf_add ON naf_add.naf_add_naf_level_5_code = naf_nomenclature.level_5_code
INNER JOIN naf_level_5 ON naf_level_5.level_5_code = naf_nomenclature.level_5_code
INNER JOIN expert ON expert.expert_level_5_code = naf_nomenclature.level_5_code
LEFT JOIN expert_rating ON expert_rating.rating_expert_id = expert.expert_id
WHERE
naf_add.FIELD_IMPORTANT LIKE '%elec%' OR
naf_level_5.FIELD_2 LIKE '%elec%'
GROUP BY expert.expert_name
ORDER BY fword DESC, avg_rating_global DESC
非常感謝。這非常直觀! – gentleboy