jbradley04 Posted November 2, 2009 Share Posted November 2, 2009 Hello I am trying to join multiple tables in one query. I am looking for the best way to do this, I am thinking a join however, have never done one. I am trying to grab data from 3 tables. table a= I am trying to get the ID from this that equals a $variable table b= I will take id from table a and make sure the this id equals the gameid from table b table c= I want to get all stats from this table that match gameid. Is this possible? if so, is it join or left join? I just do not understand joins? Any help would be greatly appreciated! I hope I explained it ok! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/179916-possible-join-question-of-multiple-tables/ Share on other sites More sharing options...
jbradley04 Posted November 2, 2009 Author Share Posted November 2, 2009 This is what I have??? $testquery = "SELECT game.id, offense.id". "FROM game, offense". "WHERE game.sID = '$sid'"; Is this correct? or close??? Quote Link to comment https://forums.phpfreaks.com/topic/179916-possible-join-question-of-multiple-tables/#findComment-949153 Share on other sites More sharing options...
dreamwest Posted November 2, 2009 Share Posted November 2, 2009 This is what I have??? $testquery = "SELECT game.id, offense.id". "FROM game, offense". "WHERE game.sID = '$sid'"; Is this correct? or close??? Tell you the truth those joins are crap...theyll drive you insane. Here is the easiest join possible: mysql_query("SELECT * FROM game AS g, offense as o WHERE g.id=o.id "); Remember less code = Happiness Quote Link to comment https://forums.phpfreaks.com/topic/179916-possible-join-question-of-multiple-tables/#findComment-949176 Share on other sites More sharing options...
Mchl Posted November 2, 2009 Share Posted November 2, 2009 Tell you the truth those joins are crap...theyll drive you insane. Here is the easiest join possible: mysql_query("SELECT * FROM game AS g, offense as o WHERE g.id=o.id "); Remember less code = Happiness I don't suppose joining on game.id and offense.id is such a good idea. They're probably primary keys for their respective tables. Quote Link to comment https://forums.phpfreaks.com/topic/179916-possible-join-question-of-multiple-tables/#findComment-949187 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.