Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread David Wellman
qlite] Syntax error using CTE and UPDATE One last thing I forgot to mention, on the topic of making INSERT and UPDATE easy - If you are using SQLite 3.15 or later, you can use Row-value functionality to UPDATE several fields in one go from a sub query. An example of how such an update query might

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread R Smith
One last thing I forgot to mention, on the topic of making INSERT and UPDATE easy - If you are using SQLite 3.15 or later, you can use Row-value functionality to UPDATE several fields in one go from a sub query. An example of how such an update query might look: WITH CTE(ID, ta, tb, tc) AS

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread R Smith
On 2017/09/04 12:46 PM, David Wellman wrote: Hi Ryan, Thanks for that. It is certainly valid syntax and I'll do some testing to check that it gives me the correct answer. It's always a pleasure. Your email has 'crossed in the post' with my second one and you've answered something that I

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread David Wellman
te-users@mailinglists.sqlite.org Subject: Re: [sqlite] Syntax error using CTE and UPDATE You are essentially trying to use a CTE (which for the intents and purposes of the UPDATE SQL is just the same as using any other table) inside an UPDATE statement as if it is the main referenced table. I

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread David Wellman
I've been able to get my code runing by changing it to the following: update relation set wamapname = (select wrk.mapname from waPSM_TABLE_MAPNAME_WRK as wrk inner join relation as rel on wrk.queryid = 1 and wrk.queryid = rel.queryid

Re: [sqlite] Syntax error using CTE and UPDATE

2017-09-04 Thread R Smith
You are essentially trying to use a CTE (which for the intents and purposes of the UPDATE SQL is just the same as using any other table) inside an UPDATE statement as if it is the main referenced table. In an UPDATE or INSERT however, there can only ever be 1 single main referenced table (i.e.