Button Press
Button Press

Reputation: 641

Select all Rows except first row

I can't seem to get this output of selecting all except the first one to work with "OFFSET". This is the one suggested as I googled

SELECT merchantid, upload_num, photosrc FROM clinics_images
WHERE merchantid = 3
OFFSET 1 ROWS

Error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OFFSET 1 ROWS LIMIT 0, 25' at line 3

Any alternativesto put in the SQL for this to work?

Upvotes: 2

Views: 2064

Answers (2)

Pirta Matharu
Pirta Matharu

Reputation: 285

select * from TableName order by Id offset 1 rows

Upvotes: -2

juergen d
juergen d

Reputation: 204746

Your error indicates that you use

OFFSET 1 ROWS LIMIT 0, 25

to get 25 records skipping the first one. The correct syntax is

SELECT merchantid, upload_num, photosrc 
FROM clinics_images
WHERE merchantid = 3
LIMIT 25 OFFSET 1

or shorter

LIMIT 1, 25

Upvotes: 4

Related Questions