Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 使用where子句连接两个表后更新列_Database_Sqlite - Fatal编程技术网

Database 使用where子句连接两个表后更新列

Database 使用where子句连接两个表后更新列,database,sqlite,Database,Sqlite,我有两张桌子 线程表 _id recipient_id type 1 1 2 1 3 2 和地址表 _id address 1 HELLO 2 BYE 收件人\u id映射到地址表的\u id 如果地址是HELLO,我需要将类型更新为特定值。我该怎么做?我已经试过了 UPDATE threads SET threads.type = 106 FROM threads INNER JOIN address

我有两张桌子

线程表

_id   recipient_id    type
 1     1
 2     1
 3     2
和地址表

_id    address
1      HELLO
2      BYE 
收件人\u id映射到地址表的\u id

如果地址是HELLO,我需要将
类型
更新为特定值。我该怎么做?我已经试过了

UPDATE   threads SET threads.type = 106 FROM threads  
   INNER JOIN 
   addresses  ON addresses._id = threads.recipient_ids
    AND
   addresses.address LIKE '%HELLO%';
但是我在“.”附近遇到了一个错误:语法错误。 更新列的正确语法是什么?

您可以使用以下运算符:

sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE threads (_id integer primary key, recipient_id integer, type text);
INSERT INTO "threads" VALUES(1,1,NULL);
INSERT INTO "threads" VALUES(2,1,NULL);
INSERT INTO "threads" VALUES(3,2,NULL);
CREATE TABLE addresses (_id integer primary key, address text);
INSERT INTO "addresses" VALUES(1,'HELLO');
INSERT INTO "addresses" VALUES(2,'BYE');
COMMIT;
sqlite> update threads set type = 106 where _id in
   ...> (select t._id from threads t, addresses  a
   ...>  where t.recipient_id = a._id and a.address like '%HELLO%');
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE threads (_id integer primary key, recipient_id integer, type text);
INSERT INTO "threads" VALUES(1,1,'106');
INSERT INTO "threads" VALUES(2,1,'106');
INSERT INTO "threads" VALUES(3,2,NULL);
CREATE TABLE addresses (_id integer primary key, address text);
INSERT INTO "addresses" VALUES(1,'HELLO');
INSERT INTO "addresses" VALUES(2,'BYE');
COMMIT;

SQLite是否支持从
更新?谢谢你的信息。我不知道。那么,如果没有来自的更新,我怎么做呢