6

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
Community
  • 1
  • 1
Jake
  • 2,942
  • 5
  • 35
  • 52

2 Answers2

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.

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

Nicola Cossu
  • 49,868
  • 15
  • 89
  • 95
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.

nobody
  • 10,126
  • 4
  • 22
  • 41
  • I would not agree it is best to just return the first row when question has asked to remove it... it is as neat as methods to remove the first row. Also there are many cases where teh row data might be large enough to not want to transport it from teh server to the application, e.g. data stored in a BLOB – Barry Apr 03 '16 at 12:08