SQL 'select' query where parameter is NULL


is it possible to run a SELECT query where the parameter is NULL?

I am trying the following but it does not work for me:



$sql = "SELECT id, categoryName FROM categories WHERE parentId=:parentId";



$parentId = NULL;		




I also tried the following without any luck:


Your query won’t work even without parameter binding. It isn’t a valid MySQL query.

You need to use something like:

WHERE ‘column’ IS NULL

Please read:


Short answer: Null = nothing, so you can’t test for column=nothing. Column can never EQUAL nothing.

Thanks a lot!

how to fetch database values in controller part using ajax variable based in my code is given error