Reputation: 285
I'm new to SQL. I have table with four columns containing values.
Example:
Id, country, adresse, dt
C1, LA, null, 2022-09-10
Null, Null,Null, 2022-09-11
Null, Null, Null, 2022-09-12
C2, null, null, 2022-10-01
I want to take all rows where id, country and adresse are not null in the same row. It means, I want to take row1, row4.
Query:
Select *
from tb1
where Id is not null and country is not null and adresse is not null
C1, LA, null, 2022-09-10
C2, null, null, 2022-10-01
It seems that my query doesn't return a row when value of id or country or adresse is null, which is not what I want to do.
Upvotes: 0
Views: 53
Reputation: 76
As you explained in the description , you should be using or
condition and not and
condition.
select * from tb1
where Id is not null or country is not null or adresse is not null
Assuming that you want to filter the rows that does not have all three values as null
.
Upvotes: 1