Search code examples
phpmysqlpearpropelphing

Select all fields where fieldone is not equal to null + Propel


I have a question about using the propel ORM and creating a query.

I have a table "locations" with fields:

  • location
  • sublocation
  • postcode
  • street
  • number

Now I want to select all the locations where the location field IS NOT equal to 'null'.
How can I do this? I've tried this but I get back all the results ...

Tried query: $locations = LocationQuery::create()->where('location' != null)->find();


Solution

  • I don't know propel. But the proper SQL syntax for the expression would be:

    $locations = LocationQuery::create()->where('location is not null')->find();
    

    Any comparison to NULL in SQL returns NULL, which is treated as false. With the exception of is null and is not null.