How do you enable LIMIT for DELETE in SQLite?

user5243421 picture user5243421 · Dec 1, 2009 · Viewed 17.1k times · Source

Using PHP, I have a simple database that may store multiple items with the same content. I want to delete the first occurrence of an instance when I use DELETE.

How do you enable LIMIT for DELETE in SQLite using PHP?

Answer

Andreas picture Andreas · Jul 20, 2012

You can use limit with select and you can combine select and delete like:

DELETE FROM Foo
WHERE someColumn in
(
  SELECT someColumn FROM FOO WHERE SomeCondition LIMIT 200
)