faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 16 people (69%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

When fetching rows from multiple tables, how do I address columns with the same name in different tables using $myrow["whatever"]?
and on same point how do you reference something like sum(revenue) within $myrow($whatever)

Sep 18th, 2000 12:42
Narendra Jain, Chris Stephens, Mark Morgan,


You have to use a query as follows:
select 
   a.user_name as name1, 
   b.user_name  as name2
from user_master as a, trx_master as b
where b.user_code = a.user_code
Now, $name1 and $name2 can now be used in your php scripts.
Similarly for sum(revenue) use your query as:
select sum(revenue) as tot_revenue
from revenue_table
where area = "$reqd_area"
Now use $tot_revenue within your php scripts.