Suppose you had a table named table1 and you have the fields
id
first_name
middle_name
last_name
in there.and in another table named table 2 you have the fields
id
table1_id
full_name
address
let us suppose that you wanted to get all the first_name from table1 where the table1 id is not equal to the id from the table2. I guess there are several ways to do this but the one that I will show to you is the NOT IN expression. You can also use the IN expression which is the opposite of the NOT IN.
Here is the code....
SELECT first_name FROM table1 WHERE id NOT IN (SELECT id FROM table2);
This may be a simple code but it can help you when the time comes.....
No comments:
Post a Comment