Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 limit results to only NULL values

Author  Topic 

noble_one
Starting Member

2 Posts

Posted - 2010-11-11 : 13:56:35
let's say i have a table that shows a car and another table that shows 4 attributes about that car. some of the attributes are populated and some arent. i left joined to the attribtues table 4 times so that i can show which attribute is populated for each car. for example:

car make color no_doors runs
pinto ford white 2 N
focus ford NULL 2 Y

left joining actually showed results for all cars in the table. i only want to show rows that have a NULL value in any one of the attributes.

what could i use?

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2010-11-11 : 14:21:15
include in your JOIN criteria: and <attribute> is null

It would be a better model for your attribute table to have 3 columns (carid, attributeid, attributeValue) so you attributes are different rows rather than different columns.

Be One with the Optimizer
TG
Go to Top of Page

noble_one
Starting Member

2 Posts

Posted - 2010-11-15 : 11:43:56
i actually put it in my where. thx.
Go to Top of Page
   

- Advertisement -