SQL Delete with join, union in Firebird

1

How would a Delete SQL Example with Join or Union be? I've seen here in stackoverflow how to do in MySQL in sql Server more in firebird I have not found or found in other forums. my SQL looks like this

DELETE FROM ANDAMENTOS_PROCESSUAIS
WHERE CODIGO_ANDAMENTO in(
  SELECT
    T2.CODIGO_ANDAMENTO
  FROM ANDAMENTOS_PROCESSUAIS T2
    LEFT JOIN PROCESSOS T3 ON T2.NUMERO_PROCESSO = T3.NUMERO_PROCESSO
  WHERE
    (T2.NUMERO_PROCESSO_AUX = T3.NUMERO_PROCESSO)  AND (T3.FASE_PROCESSO LIKE 'ARQUIVADO')    
  UNION ALL
  SELECT
    T2.CODIGO_ANDAMENTO
  FROM ANDAMENTOS_PROCESSUAIS T2
    LEFT JOIN PROCESSOS T3 ON T2.NUMERO_PROCESSO = T3.NUMERO_PROCESSO
  WHERE
    (T2.NUMERO_PROCESSO_AUX = T3.NUMERO_PROCESSO2)  AND (T3.FASE_PROCESSO2 LIKE 'ARQUIVADO'))
    
asked by anonymous 01.07.2017 / 14:35

1 answer

1

You have to use EXISTS .

Check the official manual: Firebird DELETE

DELETE FROM employee e
WHERE NOT EXISTS(
  SELECT *
  FROM employee_project ep
  WHERE e.emp_no = ep.emp_no);
    
28.10.2017 / 19:56