Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

439
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda