SQFlite-通过联接引发删除行:LEFT语法错误附近

时间:2018-12-06 14:08:02

标签: sqlite

我目前正在处理一个购物清单,该用户可以有多个清单,并且可以在不同的表上添加不同的商品。也可以检查那些项目。一切正常,但是当我要删除某些选中的项目时,会抛出错误:

  

D / Sqflite(10847):[Thread [Sqflite,5,main]]从shoppingTitles中删除   LEFT JOIN在shoppingTitles.idShopping = shopping.id上购物   在shoppingTitles.idTitles = listTitles.id上加入listTitles   shopping.checked = 1 AND listTitles.titleName =? [Einkaufsliste]   E / SQLiteLog(10847):“左”附近的(1):语法错误

这是我的SQL查询:

<center>
<table....>


</table>
</center>

我希望有人能够帮助我。预先感谢XD


基于 确定

提供的答案找到了我的解决方案
DELETE 
  FROM shoppingTitles 
    LEFT JOIN shopping ON shoppingTitles.idShopping = shopping.id
    LEFT JOIN listTitles ON shoppingTitles.idTitles = listTitles.id
  WHERE shopping.checked = 1
  AND listTitles.titleName = "Liste"

1 个答案:

答案 0 :(得分:0)

像这样尝试:

DELETE S
FROM
  shoppingTitles S
  LEFT JOIN shopping ON S.idShopping = shopping.id
  LEFT JOIN listTitles ON S.idTitles = listTitles.id
WHERE
  shopping.checked = 1
  AND listTitles.titleName = "Liste"

更新: 猜猜,JOINs语句中不支持DELETE,因此您最好找到一种使用SELECT语句的方法。 SELECT语句下面将返回一个ID。如果与您的myIdShopping相匹配,它将被删除。我无法检查/运行代码。希望它能起作用。

DELETE FROM
  shoppingTitles
WHERE
  myIdShopping IN(
    SELECT
      shoppingTitles.idShopping
    FROM
      shoppingTitles
      LEFT JOIN shopping ON shoppingTitles.idShopping = shopping.id
      LEFT JOIN listTitles ON shoppingTitles.idTitles = listTitles.id
    WHERE
      shopping.checked = 1
      AND listTitles.titleName = "Liste"
  )