SQLite Forum

Parse failure doing UPDATE FROM

Parse failure doing UPDATE FROM

(1) By anonymous on 2021-07-23 12:30:56 [link] [source]

I'm trying to do an UPDATE FROM and getting a parse failure I don't understand.  I'm wondering if anyone can explain what I'm doing wrong.  SQLite 3.23.1, built from the amalgamation.

Using the command-line shell, I do (if I've copied it correctly)

ATTACH '../customers/cust.db' AS cdb; UPDATE idmap SET btn = c.foo FROM (SELECT servID AS userId, btn AS foo FROM cdb.live GROUP BY userId, btn HAVING COUNT(*) = 1) AS c WHERE c.userId = idmap.userId

and I get

Error: near "FROM": syntax error

The subquery works fine when run on its own.  I've been staring at the syntax for UPDATE and so far have been unable to see my mistake.

(2) By Stephan Beal (stephan) on 2021-07-23 12:36:50 in reply to 1 [link] [source]

SQLite 3.23.1, built from the amalgamation.

According to https://sqlite.org/news.html update from was added in 3.33.

(3) By anonymous on 2021-07-23 12:44:07 in reply to 2 [link] [source]

Doh!  One of the reasons I dislike webpages as documentation - it's easy to version-skew (indeed, it's hard to avoid version-skew) between what you're using and the doc you're looking at.

I did try to find something helpful in the code comments, but couldn't find the UPDATE FROM doc there.  Now I know why; I should have taken that as a bigger clue.

Thank you; my apologies for the noise.  I'll be fetching newer code.

(4) By jose isaias cabrera (jicman) on 2021-07-23 13:46:29 in reply to 3 [source]

I am no expert, but I have figured out that if I am going to do anything with a tool, I would use the latest version of the tool, and then go to previous version if the need is there. :-) Just thinking out loud. :-)