我想实现的是
select * from A where id in (1,2,3) limit 5;
现在查询的是 id符合1 2 3 的条件 一共返回5条
但是我想实现的是 id符合1 2 3 的条件 每一个符合条件的数据 各返回5条,一共是15条.
求解 求大神mysqlinlimitphp

解决方案 »

  1.   

    select * from A where id=1 limit 5
    union all
    select * from A where id=2 limit 5
    union all
    select * from A where id=3 limit 5;
      

  2.   

    加入自增字段ID1
    SELECT * FROM ttha a WHERE 5>(select COUNT(*) FROM ttha WHERE 
    a.id=id AND a.id1>id1) and a.id in (1,2,3)
      

  3.   

    参考下贴中的多种方法http://blog.csdn.net/acmain_chm/article/details/4126306
    [征集]分组取最大N条记录方法征集,及散分....
      

  4.   

    神人 根据你的这个我改了适合自己的 木问题...不过 您要是不忙的话能解释下吗?
    select COUNT(*) FROM ttha WHERE 
    a.id=id AND a.id1>id1
    为什么需要自增呢 嘛意思。。
      

  5.   

    要是id唯一 那还limit什么啊
      

  6.   

    本来想演示下 只为了说明 后来发现居然冲突sorry
    WWWWA 已经解决! 谢谢您