By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

INNER JOIN Problem

exoskeleton
100+
P: 104
hi dear experts im here once again...i have a problem on showing the result when im using inner join...here's my code..

[PHP]
$sql_trans_pro_tbl="SELECT transaction_tbl.date_subscribe,transaction_tbl.dat e_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'];

}

[/PHP]

i usually do this when im using 1 table only and it works but when i make used of INNER JOIN...nothing happen...please help sir/madam..

TIA
Feb 20 '07 #1
Share this Question
Share on Google+
4 Replies


Atli
Expert 5K+
P: 5,058
Hi.

The way you write your query is very confusing.
I took it a re-aranged it so I could see what you were doing, and there is a weird cap there in your SELECT clause between t1.dat and e_expire.

Note: I'm not used to Postagre so I wrote this using as common SQL as I could master. Please correct me if I doing something MySQL specific there.
[PHP]
$sql_trans_pro_tbl = "
SELECT
t1.date_subscribe,t1.dat e_expire , t2.pro_id, t2.pro_des
FROM
transaction_tbl as t1
INNER JOIN
product_tbl as t2 ON t1.pro_id = t2.pro_id
WHERE
t1.account_name='$forder_name'
";
[/PHP]

Aside from that, you use the function pg_exec(). Are you sure you don't mean pg_execute() ? I couldn't find pg_exec() on php.net.
Feb 20 '07 #2

exoskeleton
100+
P: 104
hi im sorry..to make you confuse... its date_expire and we're using php 4.4.4 so pg_exec() is ok...

so it means i have to make use of "as" like you've written?
Feb 21 '07 #3

Atli
Expert 5K+
P: 5,058
No you can use the full table names if you want.
I just use it like this so it's easier to read.
Feb 21 '07 #4

exoskeleton
100+
P: 104
btw thank you sir
Feb 23 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.