Home > OS >  SQL show a column data only when another column is NULL
SQL show a column data only when another column is NULL

Time:02-02

I need to get data from a column only when a different column is NULL.

id_user session event
200 1 10
201 1 10
202 1 NULL

From the above I need the SQL query to only return the id_user for the event which is NULL

I am not so sure what the best method is.

CodePudding user response:

Basically, you can do this with WHERE IS NULL clause.

SELECT id_user FROM YourTable WHERE event IS NULL

CodePudding user response:

you can use WHERE event IS NULL in the query to check if the event is null,
this should get you the data you need.

in your case an example can be

SELECT id_user FROM yourTable WHERE event IS NULL;
  •  Tags:  
  • Related