现在有一个表,表中有title字段,
现在有三个关键字,比如    亚运,多哈,体操我这样写sql语句,只是按照时间顺序列出来新闻,但我想每个关键字列出一条来,我写的SQLSelect * from table 
where title like '%亚运%' || title like '%多哈%' || title like '%体操%'
group by title
order by id desc
limit 3该怎么写才能每个关键字显示1条新闻呢?谢谢了

解决方案 »

  1.   

    Select top 1 * from table 
    where title like '%亚运%' or title like '%多哈%' or title like '%体操%'
    group by title
    order by id desc
      

  2.   

    Select top 1 * from table 
    where title like '%亚运%' 
    group by title
    order by id desco 
    Select top 1 * from table 
    where title like '%多哈%' 
    group by title
    order by id descoSelect top 1 * from table 
    where title like '%体操%' 
    group by title
    order by id desco
      

  3.   


    select * from table
    where title like '%亚运%'
    limit 1
    union all
    select * from table
    where title like '%多哈%'
    limit 1
    union all
    select * from table
    where title like '%体操%'
    limit 1;
      

  4.   

    select * from table
    where title like '%亚运%'
    limit 1
    union all
    select * from table
    where title like '%多哈%'
    limit 1
    union all
    select * from table
    where title like '%体操%'
    limit 3;