sqlite&内部连接查询

eimct9ow  于 2021-08-13  发布在  Java
关注(0)|答案(2)|浏览(381)

大家好,我有一个查询,其中有3个表在连接。在access中它可以工作,但是在sqlite中它给了我一个错误,我如何“适应”sql命令?谢谢

UPDATE (
    CategoriaTB 
    INNER JOIN MagazzinoTB ON CategoriaTB.IDCategoria = 
MagazzinoTB.IDCategoria
) INNER JOIN PersoneTB ON MagazzinoTB.IDPersone = 
PersoneTB.IDPersone 
SET MagazzinoTB.DataReso = "aaa"
WHERE ((
    (PersoneTB.CodicePer)="F") 
    AND ((MagazzinoTB.Stato)=0) 
    AND ((MagazzinoTB.DataVendita) Is Null)
)
mwkjh3gx

mwkjh3gx1#

sqlite不支持 UPDATE 声明,但你可以用 EXISTS :

UPDATE MagazzinoTB 
SET DataReso = 'aaa'
WHERE Stato = 0 AND DataVendita IS NULL
  AND EXISTS (SELECT 1 FROM CategoriaTB c WHERE c.IDCategoria = MagazzinoTB.IDCategoria)
  AND EXISTS (SELECT 1 FROM PersoneTB p WHERE p.IDPersone = MagazzinoTB.IDPersone AND p.CodicePer = 'F')
bejyjqdl

bejyjqdl2#

请使用下面的查询,

UPDATE MagazzinoTB set DataReso = 'aaa' WHERE (IDCategoria, IDPersone)
IN (SELECT CategoriaTB.IDCategoria, PersoneTB.IDPersone FROM CategoriaTB 
INNER JOIN MagazzinoTB ON 
CategoriaTB.IDCategoria = MagazzinoTB.IDCategoria
INNER JOIN PersoneTB 
ON MagazzinoTB.IDPersone = PersoneTB.IDPersone
WHERE (((PersoneTB.CodicePer)="F") AND ((MagazzinoTB.Stato)=0) AND 
((MagazzinoTB.DataVendita) Is Null)));

相关问题