解决方案 »

  1.   

    第一个语句是两个查询结果的合并,而了两个查询结果都只取出2条,合起来就是4条第二个语句是合并后再取limit,是合并了以后只取出2条
      

  2.   

    select * from a where userid=1 limit 2 union all select * from a where userid=2 limit 4这样呢
      

  3.   


    select *  
    from a a1 
    where 2 >(select count(*) from a a2 where a1.userid=a2.userid and a1.id<a2.id)
         and userid in (1,2)
      

  4.   

    测试过确实是这样 select * from (select * from a where userid=1 limit 2 union all select * from a where userid=2) tmp limit 4
      

  5.   

    select * from a where userid=1 limit 2 union all select * from a where userid=2 limit 2
     //括号除掉就只能查出一条结果 为什么?这条语句相当于'
    select * from 
    ( select * from a where ..... limit 2 union all select * from a where ...... limit 2 )
    limit 
      

  6.   

    分别查询查一次,看看结果select * from a where userid=1 limit 2  
     union all
     select * from a where userid=2 limit 2
      

  7.   

    添加括号是不错的SQL编写规范。