PDA

View Full Version : Desperate for help with query using IN condition...


Antivirus
01-28-2007, 01:33 AM
I'm trying to debug this alll day, if anyone can help i'll be very very happy.

My query is as follows:

$sql = $db->query_read("
SELECT * FROM " . TABLE_PREFIX . "task AS task
WHERE 3 NOT IN (task.taskfilter)
ORDER BY name ASC
");


In my table, i have several rows & values such as the following:
taskid name taskfilter
---------------------------------------------
1 foo 4,13,22
2 baa 5,3,101
3 moo 3
4 goo 1,56,87
and so on...

my problem is that I need my result from the query to contain only rows that DO NOT have the value 3 in the taskfilter column so I only want rows 1 and 4 to return.
problem is that row 1 is being excluded as well, since there's a 3 in the number 13. What am i missing here?:confused:

calorie
01-28-2007, 02:04 AM
Untested...

$sql = $db->query_read("
SELECT * FROM " . TABLE_PREFIX . "task AS task
WHERE NOT FIND_IN_SET('3', task.taskfilter) > 0
ORDER BY task.name ASC
");

Antivirus
01-28-2007, 02:16 AM
Thank you Calorie... that worked perfectly
http://www.eclipserecords.com/forum/images/smilies/bowdown.gif

Dismounted
01-28-2007, 02:57 AM
$sql = $db->query_read("
SELECT * FROM " . TABLE_PREFIX . "task AS task
WHERE task.taskfilter <> 3
ORDER BY name ASC
");
Wouldn't that work aswell?