John Kilpatrick Sat Dec 07 04:43:59 -0500 2013

Subject: Finder Query to find all fields with NULL

Hi all,

Here is my table structure:

id user_id
(int) (int)
-----------------
1 3
2 null
3 4

I'm trying to make a query that returns all the null values in user_id;

I've tried the following without success, any help would be appreciated. Thanks

Image::find(array('conditions' => array('user_id = ?', null)));


John Kilpatrick Sat Dec 07 04:51:43 -0500 2013

I've actually done it.

Image::find_by_sql('SELECT id FROM images WHERE user_id IS NULL');

Thanks anyway

John Kilpatrick wrote:

Hi all,

Here is my table structure:

id user_id (int) (int)
1 3 2 null 3 4

I'm trying to make a query that returns all the null values in user_id;

I've tried the following without success, any help would be appreciated. Thanks

Image::find(array('conditions' => array('user_id = ?', null)));

(1-1/1)