Jump to content

ConFusInG MYSQL JOINs


diskhub

Recommended Posts

tbldb3pi.jpg\" border=\"0\" alt=\"IPB Im

 

Above there are 5 tables.

 

I have tried many joins but it didn't work.

 

 

SELECT a.***, a.**, b1.b1_name FROM tablea a, tableb b, tableb1 b1, table c WHERE (a.b_id = b.b_id AND b.b1_id = b1.b1_id AND a.c_id= c.c_id) ORDER BY a.a_id ASC

 

 

a.*** and a.** are two other colums of TABLE A.

 

 

However, it doesn't seem to work. Cos no row is produced. (0 row)

But i have double check and all tables have entry well...

 

please help

Link to comment
Share on other sites

no one can help in this?

 

 

[!--quoteo(post=326990:date=Dec 13 2005, 06:48 PM:name=diskhub)--][div class=\'quotetop\']QUOTE(diskhub @ Dec 13 2005, 06:48 PM) 326990[/snapback][/div][div class=\'quotemain\'][!--quotec--]

tbldb3pi.jpg\" border=\"0\" alt=\"IPB Im

 

Above there are 5 tables.

 

I have tried many joins but it didn't work.

SELECT a.***, a.**, b1.b1_name FROM tablea a, tableb b, tableb1 b1, table c WHERE (a.b_id = b.b_id AND b.b1_id = b1.b1_id AND a.c_id= c.c_id) ORDER BY a.a_id ASC

a.*** and a.** are two other colums of TABLE A.

However, it doesn't seem to work. Cos no row is produced. (0 row)

But i have double check and all tables have entry well...

 

please help

 

Link to comment
Share on other sites

I'm suprised that it didn't generate an error. The "table c" part should be "tablec c" if I'm correct. Change that and see what happens.

 

Also try this:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] a.***, a.**, b1.b1_name FROM tablea a LEFT JOIN tableb b ON a.b_id = b.b_id LEFT JOIN tableb1 b1 ON b.b1_id = b1.b1_id LEFT JOIN tablec c ON a.c_id= c.c_id ORDER BY a.a_id ASC [!--sql2--][/div][!--sql3--]

Link to comment
Share on other sites

[!--quoteo(post=327294:date=Dec 14 2005, 01:24 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ Dec 14 2005, 01:24 PM) 327294[/snapback][/div][div class=\'quotemain\'][!--quotec--]

I'm suprised that it didn't generate an error. The "table c" part should be "tablec c" if I'm correct. Change that and see what happens.

 

Also try this:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] a.***, a.**, b1.b1_name FROM tablea a LEFT JOIN tableb b ON a.b_id = b.b_id LEFT JOIN tableb1 b1 ON b.b1_id = b1.b1_id LEFT JOIN tablec c ON a.c_id= c.c_id ORDER BY a.a_id ASC [!--sql2--][/div][!--sql3--]

 

yes that's my typo. It is tablec c.

Nope, it produces no row.

 

Try it if u think it works... it fails badly on me. please help.

Link to comment
Share on other sites

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.