Forums
This topic is locked
INNER JOIN Problem
Posted 20 Feb 2007 02:17:01
1
has voted
20 Feb 2007 02:17:01 LorD ExoskeletoN posted:
hi dear experts...i cant able to display the result...is this correct?<pre id=code><font face=courier size=2 id=code>
$sql_trans_pro_tbl="SELECT transaction_tbl.date_subscribe,transaction_tbl.date_expire".
",product_tbl.pro_id,product_tbl.pro_des FROM transaction_tbl INNER JOIN".
" product_tbl ON transaction_tbl.pro_id=product_tbl.pro_id WHERE".
" transaction_tbl.account_name='$forder_name'";
$update_trans_pro_tbl=pg_exec($sql_trans_pro_tbl);
while($fld=pg_fetch_array($update_trans_pro_tbl)) {
$t_date_subscribe=$fld['transaction_tbl.date_subscribe'];
$t_date_expire=$fld['transaction_tbl.date_expire'];
$p_pro_id=$fld['product_tbl.pro_id'];
$p_pro_des=$fld['product_tbl.pro_des'];
}
</font id=code></pre id=code>
is this how to retrieve the result if using INNER JOIN...coz this is the way i usually do when using 1 table only...and it works but here...nothing appears in the result when i echo it...
please help ..TIA
<center>
afraid NOT to FAIL for you learn NOTHING
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></center>
Replies
Replied 20 Feb 2007 19:01:06
20 Feb 2007 19:01:06 Alan C replied:
Hola
this is not a complete answer but it may help
I had some problems with joins and found it was my sql that was wrong, I found that by echoing the query that was built - like yours, then copying that and pasting it into the sql box in phpmyadmin, once I got it working there I could see what was wrong with my query.
Hope that helps
this is not a complete answer but it may help
I had some problems with joins and found it was my sql that was wrong, I found that by echoing the query that was built - like yours, then copying that and pasting it into the sql box in phpmyadmin, once I got it working there I could see what was wrong with my query.
Hope that helps
Replied 21 Feb 2007 03:26:03
21 Feb 2007 03:26:03 LorD ExoskeletoN replied:
tnx allan c..but the problem is here for sure:
<pre id=code><font face=courier size=2 id=code>
while($fld=pg_fetch_array($update_trans_pro_tbl)) {
$t_date_subscribe=$fld['transaction_tbl.date_subscribe'];
$t_date_expire=$fld['transaction_tbl.date_expire'];
$p_pro_id=$fld['product_tbl.pro_id'];
$p_pro_des=$fld['product_tbl.pro_des'];
} </font id=code></pre id=code>
we know in ordinary retrieval done like this right? for example:
<pre id=code><font face=courier size=2 id=code>
while($fld=pg_fetch_array($update_trans_pro_tbl)) {
$t_date_subscribe=$fld['date_subscribe'];
$t_date_expire=$fld['date_expire'];
$p_pro_id=$fld['pro_id'];
$p_pro_des=$fld['pro_des'];
}
</font id=code></pre id=code>
<center>
afraid NOT to FAIL for you learn NOTHING
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></center>
<pre id=code><font face=courier size=2 id=code>
while($fld=pg_fetch_array($update_trans_pro_tbl)) {
$t_date_subscribe=$fld['transaction_tbl.date_subscribe'];
$t_date_expire=$fld['transaction_tbl.date_expire'];
$p_pro_id=$fld['product_tbl.pro_id'];
$p_pro_des=$fld['product_tbl.pro_des'];
} </font id=code></pre id=code>
we know in ordinary retrieval done like this right? for example:
<pre id=code><font face=courier size=2 id=code>
while($fld=pg_fetch_array($update_trans_pro_tbl)) {
$t_date_subscribe=$fld['date_subscribe'];
$t_date_expire=$fld['date_expire'];
$p_pro_id=$fld['pro_id'];
$p_pro_des=$fld['pro_des'];
}
</font id=code></pre id=code>
<center>
afraid NOT to FAIL for you learn NOTHING
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></center>
Replied 21 Feb 2007 19:31:43
21 Feb 2007 19:31:43 Alan C replied:
mmmmm, I have not done a lot of joins, but where I have the access to the results has been like your second example, that is
$t_date_subscribe=$fld['date_subscribe'];
I don't think you need that table name in as in the next line
$t_date_subscribe=$fld['transaction_tbl.date_subscribe'];
my understanding is that mysql does all the join internally and returns an array in exactly the same way as 'normal' so it contains all the fields that you asked for
good luck
$t_date_subscribe=$fld['date_subscribe'];
I don't think you need that table name in as in the next line
$t_date_subscribe=$fld['transaction_tbl.date_subscribe'];
my understanding is that mysql does all the join internally and returns an array in exactly the same way as 'normal' so it contains all the fields that you asked for
good luck
Replied 23 Feb 2007 09:42:45
23 Feb 2007 09:42:45 LorD ExoskeletoN replied:
ah ok thank you very much Sir Alan C...
i really appreciate your help..
<center>
afraid NOT to FAIL for you learn NOTHING
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></center>
i really appreciate your help..
<center>
afraid NOT to FAIL for you learn NOTHING
www.nasbikesphilippines.bravehost.com
<img src="www.motorcyclephilippines.com/forums/signaturepics/sigpic14460_2.gif" border=0></center>
Replied 23 Feb 2007 17:48:29
23 Feb 2007 17:48:29 Alan C replied:
I'm really pleased it worked - your comment made my day!