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
Find duplicate values in one column First, use the GROUP BY clause to group all rows by the target column, which is the column that you want to check duplicate. Then, use the COUNT() function in the HAVING clause to check if any group have more than 1 element. These groups are duplicate.
Eliminating Duplicates from a Query Resultmysql> SELECT DISTINCT last_name, first_name -> FROM person_tbl -> ORDER BY last_name; An alternative to the DISTINCT command is to add a GROUP BY clause that names the columns you are selecting.
The query uses window version of COUNT aggregate function: the function is applied over Col1 partitions. The outer query filters out records which have a Col1 value that appears only once. Show activity on this post.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With