SQL-根据传递的值数量,更改子句值的数量

发布于 2025-02-14 02:14:07 字数 439 浏览 1 评论 0原文

我已经加入了2个表,并试图根据顺序删除行。ID

DELETE order_attachment
FROM order
LEFT OUTER JOIN order_attachment
ON order.id=order_attachment.id
WHERE order.id = ?

现在问题是订单数量。ID可以是1、2或3,它们作为数组出现。 (例如[12311]或[12323,45612]或[23413,55675,32512])

我想用单个交易中的order_attachment表中的所有行中删除所有行。

问题

  1. 如何通过一次交易删除所有行?
  2. 如何根据OrderID数组长度更改的数量? (1个问号长度是1、2,如果长度为2,则长度为3),如果长度为3)

谢谢!

I have joined 2 tables and trying to delete the rows based on the order.id

DELETE order_attachment
FROM order
LEFT OUTER JOIN order_attachment
ON order.id=order_attachment.id
WHERE order.id = ?

Now the problem is number of order.id can be 1, 2, or 3 and they come in as an array.
(Ex. [12311] or [12323, 45612] or [23413, 55675, 32512])

I want to delete all the rows in order_attachment table with the order.id with a single transaction.

Questions

  1. How can I delete all the rows with a single transaction?
  2. How can I change the number of ? based on orderId array length?
    (1 question mark if length is 1, 2 if length is 2, and 3 if length is 3)

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文