我想借助其他表的外鍵更新一個表。如何在SQLite中使用select語句更新表
我試圖做這樣的事情:
UPDATE tbl_1
SET field1 = 6, field12 = NULL
WHERE field3 = (SELECT tbl_2.item1
FROM tbl_1, tbl_2
WHERE tbl_1.field3 = tbl_2.item1 AND tbl_2.item2 = 135)
OR
UPDATE tbl_1
SET field1 = 6, field12 = NULL
WHERE field3 = (SELECT item1 FROM tbl_2 WHERE item2 = 135)
SELECT子句返回多少個值? – Teja 2012-04-05 11:25:34
在第二個我很確定你只需要改變'WHERE Field3 =(SELECT ...'到'WHERE Field3 IN(SELECT ...',在第一個我認爲你需要改變'Where Field3 =(SELECT..'爲'WHERE EXISTS(SELECT ...') – GarethD 2012-04-05 11:26:03