MYSQL获得所有结果,但首先[重复]

时间:2021-12-22 06:57:13

Possible Duplicate:
Mysql Offset Infinite rows

可能重复:Mysql Offset无限行

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

2 个解决方案

#1


14  

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.

其中x是一个足以包含所有记录的数字。

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

或者使用,而不是x,18446744073709551615,这是bigint unsigned的最大值。

#2


3  

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.

获得一个额外的行不会真正损害您的表现。

#1


14  

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.

其中x是一个足以包含所有记录的数字。

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

或者使用,而不是x,18446744073709551615,这是bigint unsigned的最大值。

#2


3  

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.

获得一个额外的行不会真正损害您的表现。