Merge two select, how do I do?

Asked

Viewed 152 times

0

How to join 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);
  • Obs I need to call both select to play sql, I wanted to know how I do it, if I use Union?

  • you want to display the two queries or unite(Union) them?

  • Open two tabs doesn’t solve the problem? I haven’t figured out what you want yet.

  • Merge them in select

  • Standardize the fields of the two selects and use UNION ALL

  • I’m trying here only it’s not working.

  • I edited the question because "phpmyadmin" is not a "database", read this to understand the differences: What is the difference between mysql and phpmyadmin?

Show 2 more comments

1 answer

0

Try to do 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);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.