Jump to content

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.

 

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.