Re: How to display my results?

From: Date: Mon, 10 Mar 2003 09:12:10 +0000
Subject: Re: How to display my results?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-4123@lists.php.net to get a copy of this message
Charles Kline wrote:
I have been messing with this query ALL DAY. I have finally gotten MySQL to return the results I am looking for (in phpMyAdmin) but I am using PEAR DB on my pages and I can't figure out how to get to the data I need from this query. Here is the query: SELECT
    tbl_funding.area_1,
    areas1.area_name,
    tbl_funding.area_2,
    areas2.area_name
FROM
    tbl_funding
        LEFT JOIN tbl_dra areas1 ON tbl_funding.area_1 = areas1.id
        LEFT JOIN tbl_dra areas2 ON tbl_funding.area_2 = areas2.id
I get this returned when I try this in phpMyAdmin:
area_1     area     area_2     area
4         Health Services and Systems         5            Mental Illness
3         Chronic Diseases                              0            NULL
1         Acute and Traumatic Injury              2           Aging and Age
So, there are two columns returned with the name area. I have no idea what to do with this - I am trying to display the names that are in the area fields. Any clue? Thanks Charles Hi
Try something like this SELECT tbl_funding.area_1, areas1.area_name AS area1, tbl_funding.area_2, areas2.area_name AS area2 FROM tbl_funding
       LEFT JOIN tbl_dra areas1 ON tbl_funding.area_1 = areas1.id
       LEFT JOIN tbl_dra areas2 ON tbl_funding.area_2 = areas2.id
- Jeroen

« previous php.pear.general (#4123) next »