Please don't light me up for this post...
Posted: Fri Jun 07, 2013 1:24 am
I'm trying to create an array variable from a simple SQL query to use in a NOT IN() function in another SQL query. I have an ID field in Table 2 that corresponds to an ID field in Table 1. The relationship is Table 1 one to Table 2 many. I have been successful creating the second SQL query however, I only get the last ID from Table 2.
Here is an example of my code:
Any help would be greatly appreciated.
pickle | Please use [ syntax=php ], [ syntax=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Here is an example of my code:
Code: Select all
$query = "SELECT * FROM Table2 WHERE `mbr_member_id` = '$v_mbr_id'";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
{
$variable = $row['friend_of'];
}
$rand_mbr = "SELECT * FROM Table1 WHERE `act`='Y' AND `lck`='N' AND `member_id` != '$v_mbr_id' AND `member_id` NOT IN ('$variable') ORDER BY RAND() LIMIT 5"; pickle | Please use [ syntax=php ], [ syntax=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: