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
https://forums.phpfreaks.com/topic/3036-confusing-mysql-joins/
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
https://forums.phpfreaks.com/topic/3036-confusing-mysql-joins/#findComment-10183
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
https://forums.phpfreaks.com/topic/3036-confusing-mysql-joins/#findComment-10185
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
https://forums.phpfreaks.com/topic/3036-confusing-mysql-joins/#findComment-10194
Share on other sites

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.