Search code examples
mysqlwhere-clausenotnull

MYSQL where not null for at least one column


There is a cross join table needs to capture rows with at least one not null value for specific columns:

where books.id is not null 
or typings.id is not null
or translates.id is not null

is there any function or method to prevent duplicate not null in that where clause?

something like this :
where at_Least_not_Null_One_Of(books.id,typigns.id,translates.id)


Solution

  • Use COALESCE:

    COALESCE(books.id,typigns.id,translates.id) IS NOT NULL