UPDATE TOP in Sqlite
Is it possible to update the first row and WHERE clause.
I have tried:
UPDATE TOP (1) Players SET... WHERE...
and
UPDATE TOP 1 Players SET... WHERE
But it looks like there is no TOP in sqlite. Can I use an alternative?
Or am I doing something wrong?
+3
René Beneš
source
to share
2 answers
Try
UPDATE Players SET... WHERE... LIMIT 1
I can't confirm right now, but maybe LIMIT
only works with operators SELECT
. If so:
UPDATE Players SET... WHERE ID in (SELECT ID FROM Players WHERE ... LIMIT 1)
+5
juergen d
source
to share
SQLite supports TOP N queries, but uses a LIMIT clause to accomplish this. Anyway, this is only for SELECT statements, not for UPDATE. If you only want to update one row, you need to filter the UPDATE using the WHERE clause.
Edit:
I'm fixing it, the UPDATE statement appears to support the LIMIT clause .
0
mgnoonan
source
to share