[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-17 Thread James K. Lowden
On Sat, 16 Jan 2016 14:26:20 -0700 "Keith Medcalf" wrote: > > the result is nondeterministic if more than one row in S matches. > > The update applies all rows in S matching T. Of course, only the > > last one is preserved. Of course, because order is nonsemantic, > > there's no way to know

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread R Smith
On 2016/01/16 10:18 AM, audio muze wrote: > Thanks Keith > > That's what I'd tried with my first attempt but naturally it didn't work. > > Why is it that SQLite does not support a FROM clause in an update statement? Because of the intent expressed with the word "Lite" in SQLite and the fact

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread James K. Lowden
On Sat, 16 Jan 2016 10:18:28 +0200 audio muze wrote: > Why is it that SQLite does not support a FROM clause in an update > statement? I can't answer why, but I can tell you it's fraught with potential error. Inventing syntax runs the risk of supporting undesirable behavior. SQL Server has

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread Keith Medcalf
> I can't answer why, but I can tell you it's fraught with potential > error. Inventing syntax runs the risk of supporting undesirable > behavior. > > SQL Server has such a syntax. Unfortunately, when you say: > > update T ... from S Pretty much everything does. Yes, Sybase Transact

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread audio muze
Thanks Keith That's what I'd tried with my first attempt but naturally it didn't work. Why is it that SQLite does not support a FROM clause in an update statement? On Sat, Jan 16, 2016 at 10:07 AM, Keith Medcalf wrote: > > Of course, if there was a FROM clause for UPDATE it would be as simple

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread audio muze
> Is it a typo in inner query or you ARE asking for a resource from target? Apologies all, I'm fast asleep, it should've read: UPDATE target SET resource = ( SELECT s.resource FROM source s WHERE ( s.ID = ID AND s.resource IS NOT NULL ) );

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread audio muze
Apologies if I'm asking an obvious question, but I've searched and tried various options and have not been able to arrive at an UPDATE statement in SQLite that does what I need. I've two tables with a unique identifier that enables me to link them. I'm wanting to update the values of a particular

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread Igor Korot
Hi, On Sat, Jan 16, 2016 at 12:58 AM, audio muze wrote: > Apologies if I'm asking an obvious question, but I've searched and > tried various options and have not been able to arrive at an UPDATE > statement in SQLite that does what I need. > > I've two tables with a unique identifier that

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread Keith Medcalf
Of course, if there was a FROM clause for UPDATE it would be as simple as: UPDATE target SET resource = source.resource FROM source WHERE source.id = target.id AND source.resource IS NOT NULL; This is semantically the same as: SELECT ... FROM target, source WHERE source.id =

[sqlite] Updating the contents of a field in table A with the value of the same field in table B

2016-01-16 Thread Keith Medcalf
On Friday, 15 January, 2016 22:58, audio muze said: > Apologies if I'm asking an obvious question, but I've searched and > tried various options and have not been able to arrive at an UPDATE > statement in SQLite that does what I need. > I've two tables with a unique identifier that enables me