MySQL Group By Pair整数范围

时间:2012-01-03 04:08:28

标签: mysql sql

我在MySQL中有一个表。 IdPictureNoId为自动,PictureNo任何顺序(1,2,3)

http://i42.tinypic.com/jjaeyx.jpg http://i42.tinypic.com/jjaeyx.jpg

问题是我想通过pictureNo对检索如下,Id的顺序无关紧要,只需要按对检索,应该是1,2,3

http://i40.tinypic.com/jiku54.jpg http://i40.tinypic.com/jiku54.jpg

谢谢!

2 个答案:

答案 0 :(得分:0)

试试这个:

SELECT * from MyTable order by PictureNo + ID , PictureNo

答案 1 :(得分:0)

尝试:


SELECT *
FROM (
  SELECT ID,PictureNo
  FROM table_name
  GROUP BY ID
) AS s
ORDER BY s.ID; 

希望有所帮助