Join two select, what should I do?

0

How to merge these two SELECTS?

SELECT *
FROM doacao d
LEFT JOIN foto f ON (d.iddoacao = f.iddoacao)
WHERE (d.idbeneficiario IS NULL);

SELECT email
FROM doador dd
INNER JOIN doacao d ON (dd.iddoador = d.iddoador)
WHERE (dd.iddoador IS NOT NULL)
  AND (d.idbeneficiario IS NULL);
    
asked by anonymous 30.06.2016 / 00:53

1 answer

0

Try this:

SELECT email, d.*
FROM doador dd
INNER JOIN doacao d ON (dd.iddoador = d.iddoador),
LEFT JOIN foto f ON (d.iddoacao = f.iddoacao)
WHERE (dd.iddoador IS NOT NULL)
      AND (d.idbeneficiario IS NULL);
    
30.06.2016 / 04:11