Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql: 'WHERE something!=true' excludes fields with NULL

I have a 2 tables, one in which I have groups, the other where I set user restrictions of which groups are seen. When I do LEFT JOIN and specify no condition, it shows me all records. When I do WHERE group_hide.hide!='true' it only shows these records that have false enum type set to them. With JOIN, other groups get the hide field set as "NULL". How can I make it so that it excludes only these that are set to true, and show everything else that has either NULL or false?

like image 773
WraithLux Avatar asked Apr 12 '26 09:04

WraithLux


1 Answers

In MySQL you must use IS NULL or IS NOT NULL when dealing with nullable values.

HEre you should use (group_hide.hide IS NULL OR group_hide.hide != 'true')

like image 184
Don Avatar answered Apr 13 '26 23:04

Don