求助关于SQL语句(多关键字查询)

来源:百度知道 编辑:UC知道 时间:2024/06/03 14:09:39
求教高手,我想查询table 里面的 content 字段里面包含有a,b,c然后排序查询出来!
排序规则:先查询出同时满足包含a,b,c的,然后再查出包含其中2项目的,最后只要包含其中一项目的!
能否用一条SQL处理?谢谢高手

select content from table where content like '%a%' and content like '%b%' and content like '%c%' order by content union all

select content from table where ((content like '%a%' and content like '%b%') or (content like '%b%' and content like '%c%') or (content like '%a%' and content like '%c%')) and content not in (select content from table where content like '%a%' and content like '%b%' and content like '%c%') order by content union all

select content from table where (content like '%a%') or (content like '%b%') or (content like '%c%') and content not in (select content from table where content like '%a%' and content like '%b%' and content like '%c%' order by content union all
select content from table where ((content like '%a%' and content like '%b%') or (content like '%b%' and content l