How can I select with exception in mySQL -
select department mytable contact null
department contact ------------- --------- cleaning jack admin peter software james cleaning (null) cleaning jill hardware (null)
in table above, how can select department contact null excluding existed contact.
the statement above return "cleaning" , "hardware".
what expected "hardware"
how can select "hardware" or possible.
tia
i think want return rows not have non-null contacts.
select distinct department mytable contact null , department not in (select department mytable contact not null)
or, if want without in
clause:
select distinct a.[department] mytable left outer join mytable b on b.[department] = a.[department] , b.[contact] not null a.[contact] null , b.[contact] null
self join using not null
condition, verify join
failed checking null
in where
clause.
Comments
Post a Comment