tommyda Posted November 27, 2009 Share Posted November 27, 2009 Hi I have 3 tables, one with a list of genres, one with movie listings and one to assign genres to the movie listings. Genres id, name Videolistings id, name, title, img Assign type, typeid, vlid I would l to pull the list of genres and all the movie listing details in the same query, I have managed to achieve this but only using 3 separate queries but it looks messy and I know there must be a more efficient way of doing this. currently I am selecting all the rows from the assign table where type=genre and vlid=1 then in a while loop I am selecting * from videolistings to get the info and selecting name from genres. <?php $getgenrelist=mysql_query("SELECT * FROM assign WHERE type='genre' AND typeid='$vlid'") or die(myslq_error()); while($row = mysql_fetch_array($getgenrelist)) { $getvideo = mysql_query("SELECT * FROM videolistings WHERE id ='$row[vlid]' "); $video = mysql_fetch_array($getvideo); $getgenre = mysql_query("SELECT name FROM genres WHERE id = '$row[typeid]'") while($genre= mysql_fetch_array($getgenre)) { $genres.=$genre['name']; }; echo $Video name $img $genres....... }; }; ?> So if anyone can help that would be much appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/183170-is-there-a-way-to-combine-these-3-queries-into-one/ Share on other sites More sharing options...
tommyda Posted November 28, 2009 Author Share Posted November 28, 2009 please disregard this post ive sorted it Link to comment https://forums.phpfreaks.com/topic/183170-is-there-a-way-to-combine-these-3-queries-into-one/#findComment-966711 Share on other sites More sharing options...
fenway Posted November 28, 2009 Share Posted November 28, 2009 please disregard this post ive sorted it How? Link to comment https://forums.phpfreaks.com/topic/183170-is-there-a-way-to-combine-these-3-queries-into-one/#findComment-967056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.