Reputation: 308
I want to create a procedure that checks the data in 'Table1' against the data in 'Table2'. I have used this query to perform the procedure.
$sq_query = 'SELECT * FROM Table1 WHERE NOT EXISTS (SELECT * FROM Table2 WHERE Table1.name = Table2.name)';
$result = mysqli_query($conn, $sq_query);
if (!$result) {
die ('SQL Error: ' . mysqli_error($conn));
}
BTW, I want to find out any name
which isn't in 'Table2' but is in 'Table1'. I have been unsuccessful in locating missing files so far.
Upvotes: 0
Views: 41
Reputation: 37473
You can try using left join
SELECT * FROM table1 left join
Table2 on Table1.name = Table2.name
where Table2.name is null
Upvotes: 1