Jump to content


Photo

Multiple Joins


  • Please log in to reply
5 replies to this topic

#1 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 30 December 2005 - 11:35 PM

Table 1 has fields a,b,c,d

Table 2 has fields a,b,f,g

Table 3 has fields a,h,f


Can I join:
table1 a - table2 a,
table2 a - table3 a,
table2 f - table3 f

???

(This is a leaning exersize on my part, so don't kill yourself!)
I Can't figure this out. I know my query browser will allow me to make the links, but I don't really understand it well enough to use it...
BUT, I did a three table query today without JOINS, and it took FOREVER!!!

Thanks!

#2 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 31 December 2005 - 01:00 AM

erm you could make a script which copys the info from one table to another.
like.
$query = mysql_query("SELECT a FROM table1 WHERE row=a'");
$valuea = mysql_result($query, 0, "a");
mysql_query("INSERT INTO table1 (a) VALUES ($valuea)");
                     UPDATE

This code might not work because of mysql_result but its just a quick code. Its just ideas. Hope i helped

#3 Arenium

Arenium
  • Staff Alumni
  • Advanced Member
  • 111 posts
  • LocationMassachusetts

Posted 31 December 2005 - 03:37 AM

My favorite intro to JOINs: [a href=\"http://hashmysql.org/index.php?title=Introduction_to_Joins\" target=\"_blank\"]Intro[/a]; [a href=\"http://hashmysql.org/index.php?title=More_Advanced_Joins\" target=\"_blank\"]More Advanced[/a]. With a little bit of knowledge you can certainly accomplish this join entirely on your own. And since this is a learning exercise, that is the idea, no?

#4 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 31 December 2005 - 06:14 AM

In the spirit of the learning exercise, I won't give you the answer -- just remember that for each relation, you need a set of tables and a join condition; that should help point you in the right direction, especially after reading those tutorials. Good luck!
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 31 December 2005 - 12:22 PM

????

Those links are both dead???

:/

[!--quoteo(post=331750:date=Dec 30 2005, 10:37 PM:name=Arenium)--][div class=\'quotetop\']QUOTE(Arenium @ Dec 30 2005, 10:37 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
My favorite intro to JOINs: [a href=\"http://hashmysql.org/index.php?title=Introduction_to_Joins\" target=\"_blank\"]Intro[/a]; [a href=\"http://hashmysql.org/index.php?title=More_Advanced_Joins\" target=\"_blank\"]More Advanced[/a]. With a little bit of knowledge you can certainly accomplish this join entirely on your own. And since this is a learning exercise, that is the idea, no?
[/quote]


#6 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 31 December 2005 - 04:51 PM

Must be a temporary outage -- the whole site seems like it's down for now, though it was working just fine yesterday.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users