jiraiya
jiraiya

Reputation: 997

Frustrating error with sqlite cross table update

For some reason the following query returns the following error message in sqlite. I normally use cross table joins but as this is not possible for updates in sqlite it's a sub-query instead. This could be a case of tired eyes but I can't seem to see the issue. Any help is appreciated.

near "." : Syntax Error

  UPDATE
    tbl1
    set tbl1.[some_field1] = (SELECT tbl2.[some_fieldA]||substr(tbl2.[some_fieldB],1,2)     
                              FROM tbl2
                               WHERE tbl2.[some_fieldC] = tbl1.[some_field2])
  WHERE
    tbl1.[file_name] = "some_arbitrary_file.txt"
    AND tbl1.[some_field1] IS NULL 
    OR tbl1.[some_field1] = "";

Upvotes: 1

Views: 118

Answers (1)

CL.
CL.

Reputation: 180080

The UPDATE command handles only one table, so it is never necessary to specify the table for the columns to be updated. Drop the tbl1. in the SET:

... SET [some_field1] = ...

Upvotes: 1

Related Questions