1

I am trying to execute this statement in DB Browser:

UPDATE p SET SourceId = s.Id 
FROM Practice p INNER JOIN Source s ON  p.Source = s.Name

And it is refusing to execute complaining that says:

there is a syntax error near "FROM"

What am I doing incorrectly here?

shA.t
  • 16,580
  • 5
  • 54
  • 111
pthalacker
  • 2,056
  • 3
  • 20
  • 37
  • @Pheonixblade9 How are those answers different from my t-sql – pthalacker Apr 30 '15 at 01:41
  • 2
    [SQLite doesn't support JOINs in UPDATE statements](http://sqlite.org/lang%5Fupdate.html), Use [IN statement](http://stackoverflow.com/a/774300/4519059) ;). – shA.t Apr 30 '15 at 06:44
  • Coming to this in 2022: it seems there's a bug in DB Browser for SQLite where queries break if you break the SQL up over multiple lines. Very annoying. – spops Oct 21 '22 at 22:36

2 Answers2

-1

you need to replace Source by [Source]

Vasily
  • 5,707
  • 3
  • 19
  • 34
-1

Source is a keyword in SQL used for MERGE JOINs.

Put brackets around it to force it to be used as a string literal:

UPDATE p 
SET SourceId = s.Id 
FROM Practice p 
INNER JOIN [Source] s 
ON p.[Source] = s.[Name]
Codeman
  • 12,157
  • 10
  • 53
  • 91