Jump to content

Possible Join Question of multiple tables?


jbradley04

Recommended Posts

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  :shrug:

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

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.

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.