We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44231
    • 126 Posts
    hi there

    Im doing a XPDO query which contains IS NULL function but it seems it is not working what might be the problem??

    here's my code
     $query->leftJoin('Tablesearch', 'Tsearch', array(" Tblbooks.system_brands_id = Tsearch.system_brand_id")); 
            $query->where(array("Tsearch.system_brand_id:IS" => "null"));
            $query->groupby('system_brands_id');


    this is the error
     [2013-07-29 09:12:13] (ERROR @ /index.php) Error 42000 executing statement: 
    Array
    (
        [0] => 42000
        [1] => 1064
        [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''null' GROUP BY system_brands_id' at line 1
    )
    
    • Quote from: johnrobert27 at Jul 29, 2013, 09:12 AM

        $query->leftJoin('Tablesearch', 'Tsearch', array(" Tblbooks.system_brands_id = Tsearch.system_brand_id")); 
        $query->where(array("Tsearch.system_brand_id:IS" => "null"));
        $query->groupby('system_brands_id');


        $query->leftJoin('Tablesearch', 'Tsearch', array(" Tblbooks.system_brands_id = Tsearch.system_brand_id")); 
        $query->where(array("Tsearch.system_brand_id:IS" => NULL));
        $query->groupby('system_brands_id');


      You need to use PHP NULL, not a string with the word null.