开发者

MYSQL get all results but first [duplicate]

开发者 https://www.devze.com 2023-03-29 00:19 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Mysql Offset Infinite rows
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Mysql Offset Infinite rows

I am trying to get all results for a query BUT NOT the first one, I have the following but its giving me an error, please help; thanks.

SELECT 开发者_运维百科DISTINCT `memberID` FROM `discusComments` 
WHERE `topicID` = 4 ORDER BY `id` DESC OFFSET 1


SELECT DISTINCT `memberID` 
FROM `discusComments` 
WHERE `topicID` = 4 
ORDER BY `id` 
DESC limit 1,x

where x is a number enough great to contain all your records.

or use, instead of x, 18446744073709551615, that is maximum value of bigint unsigned.


Ignore the first row when you receive the results in your application. It is much neater than using an ugly query like:

SELECT * FROM my_table LIMIT 1, 18446744073709551615

Getting one extra row will not really hurt your performance.

0

精彩评论

暂无评论...
验证码 换一张
取 消