Reputation: 813
I want to create a table C which contains column from Table A (customer_id ) and Table B (customer_id) which contains all customer_id from table A which are not in Table B. I wrote the following query but it didn't get any data populated.
create table C AS
select *
from (
select customer_id
from A al
join B bl
on al.customer_id=bl.customer_id
where bl.customer_id is null
) x;
This query shows 0 results.
Upvotes: 0
Views: 217
Reputation: 1401
SELECT a1.customer_id
FROM
A a1 LEFT OUTER JOIN
B b1 ON a1.customer_id = b1.customer_id
WHERE b1.customer_id IS NULL;
That should do the thing.
Regards, Dino
Upvotes: 2