2
I need to check if a particular e-mail exists in two tables, if it exists in one of the two tables the user will not be able to register, facilitating would be the code below, the column email is present in the two tables;
SELECT * FROM tab1, tab2 WHERE email = :email
I’ve tried to
SELECT
usuarios.email, usr_pend.email
FROM usuarios, usr_pend
WHERE usuarios.email = :email
OR usr_pend.email = :email
And I also tried
SELECT
usr.*, pen.*
FROM usuarios usr
INNER JOIN usr_pend pen
ON usr.email = :email
OR pen.email = :email
But both forms return 0, when in fact the email is present in one of them, as I should do this check?
I was able to understand the answers there, I already altered and put here, it worked perfectly, but thanks anyway ^
– Leo Letto
Anyway, I edited the answer simplifying to serve in simpler cases, if you want to take a look. This is as a general solution :)
– Bacco
Opa, thanks for simplifying, it became easier to understand what happens when we use UNION, thanks again ;)
– Leo Letto