Simple DELETE with safety LIMIT throws a syntax error:
DELETE FROM system."products" LIMIT 1
ERROR: Syntax ERROR at "LIMIT"
SQL state: 42601
How do I limit the amount of rows to delete?
(PostgresSQL version 9.6)
You can use LIMIT only in the SELECT statement.
Try this:
DELETE FROM system."products" WHERE id IN (SELECT id FROM system."products" LIMIT 1)
Otherwise you can have something like this
DELETE FROM system."products" WHERE id bewteen ? and ?
Obviously this can work only if there is in your table an unique column (named id in my examples)!
IN() is evil, is there no other way?
LIMITin ANSI SQL (not for DELETE, nor for any other SQL command)