By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE temp_1 (
id int,
Email varchar(20),
Pass varchar(20)
);
INSERT INTO temp_1 (id, Email, Pass)
VALUES
(1, 'abc@abc.com', 'rgjoegeijerioge'),
(2, 'ab46c@abc.com', 'dgnkjrkjhrnjkrt'),
(3, 'ab46bbbb@abc.com', 'etjhrnkrjkjhjhr');
CREATE TABLE temp_2 (
transferid int,
account varchar(20),
accountto varchar(20),
item varchar(10)
);
INSERT INTO temp_2 (transferid, account, accountto, item)
VALUES
(1, 'abc@abc.com', 'rjek@xs.com', 'book1'),
(2, 'ab4gtrc@abc.com', 'xbjk@abc.com', 'book2'),
(3, 'ab46gggc@abc.com', 'ab46c@abc.com', 'book2');
SELECT
*
FROM
temp_1
LEFT JOIN temp_2
ON temp_1.Email = temp_2.account OR temp_1.Email = temp_2.accountto
WHERE
temp_2.account IS NULL
id | Pass | transferid | account | accountto | item | |
---|---|---|---|---|---|---|
3 | ab46bbbb@abc.com | etjhrnkrjkjhjhr | null | null | null | null |