有四个中文词(中国,美国,法国,日本),请写一个sql语句,按排列组合的形式去数据库表查询,假设表名为article,要查询的字段名是 content,按匹配的词语多少依次显示结果,例如同时匹配到4个词的就放在最前面,仅匹配到其中一个词的排在最后面。
SELECT content, ( CASE WHEN content LIKE '%中国%' AND content LIKE '%美国%' AND content LIKE '%法国%' AND content LIKE '%日本%' THEN 4 WHEN content LIKE '%中国%' AND content LIKE '%美国%' AND content LIKE '%法国%' OR content LIKE '%中国%' AND content LIKE '%美国%' AND content LIKE '%日本%' OR content LIKE '%中国%' AND content LIKE '%法国%' AND content LIKE '%日本%' OR content LIKE '%美国%' AND content LIKE '%法国%' AND content LIKE '%日本%' THEN 3 WHEN content LIKE '%中国%' AND content LIKE '%美国%' OR content LIKE '%中国%' AND content LIKE '%法国%' OR content LIKE '%中国%' AND content LIKE '%日本%' OR content LIKE '%美国%' AND content LIKE '%法国%' OR content LIKE '%美国%' AND content LIKE '%日本%' OR content LIKE '%法国%' AND content LIKE '%日本%' THEN 2 WHEN content LIKE '%中国%' OR content LIKE '%美国%' OR content LIKE '%法国%' OR content LIKE '%日本%' THEN 1 ELSE 0 END ) AS match_count FROM article ORDER BY match_count DESC, content;