user2924127 user2924127 - 1 year ago 72
SQL Question

Why does this query return values in the column

I have the following query:

FROM table_a a ,
table_c c
WHERE = AND IN (SELECT id from table_c where c_date is null);

I have two tables,

I join these two tables, but then get use an
statement to only show the id's for in which are in
AND have the c_date column set to null`.

This query though returns
id, and c_date values, and some of the c_date values are not null
, how is this possible?

I thought in my sub query I am only selecting id which have null c_dates?

Answer Source

This should work without the subquery assuming you don't want to return null dates. Please note the use of the join:

FROM table_a a 
    JOIN table_c c ON =  
WHERE c_date is null;

It's difficult to answer your specific question though without sample data and expected results. You probably have multiple records in table_c that match the id field in table_a.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download