I'm not sure why this worked - but it did.
Many thanks
On May 25, 2007, at 8:46 AM, Samuel R. Neff wrote:
Try this
UPDATE table1
SET column3 = (
SELECT column3
FROM table2
WHERE table2.column1 = table1.column1
AND table2.column2 = table1.column2)
HTH,
Sam
-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building
products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
-----Original Message-----
From: Brian Albert [mailto:[EMAIL PROTECTED]
Sent: Friday, May 25, 2007 11:30 AM
To: sqlite-users@sqlite.org
Subject: [sqlite] Why doesn't this UPDATE work?
I've been struggling with the following:
update table1 set column3 = (select i.colum3 from table2 i, table1 t
where t.column1 = i.column1 and t.column2 = i.column2)
Reading the manual and this list I learned that this statement will
grab the first result of my sub-select and populate it in every row
(cruel, but I can see the logic). However what I want is for the
different values that I get from the sub-select to be entered into
the appropriate rows of column3.
I looked at using INSERT or REPLACE but the subselect (when run
standalone) returns 34001 rows, and table1 has 34004 rows - the
result is all 125000 rows of table2 being appended to table1 (with
NULLs in all but column3).
Neither table has a primary key and I'm running 3.3.17 on MacOSX
10.4.9
Is UPDATE the correct way to do this? Also, is there an SQLITE
chatroom on IRC?
Many thanks in advance.
----------------------------------------------------------------------
------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------
------
-
----------------------------------------------------------------------
-------
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------
-------
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------