Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

436
Views
SQL - change the number of where clause values depending on number of values passed in

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!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!