What I'm trying to do is get the results of the first query, pass them to an array, and then use them in a subquery. Both queries work separately if I manually enter the identifier in a subquery. Is there a way to link these two queries?
I used this code
$result = mysql_query("SELECT v2.video_id as v2id FROM VideoTags AS v1 JOIN VideoTags AS v2 USING ( tag_id ) WHERE v1.video_id =1 AND v1.video_id <> v2.video_id GROUP BY v2.video_id ORDER BY COUNT( * ) DESC");
$values = array();
while ($row = mysql_fetch_array( $result )) {
$values[] = $row['v2id'];
}
echo join(", ", $values);
$resultone = mysql_query("SELECT * FROM videos WHERE video_id IN (' . join(',', $values). ')");
while ($row = mysql_fetch_array( $resultone )) {
echo "name ".$row['video_name'];
}
Thank you for your help.
source
share