Help me in fetching records.

Discussion in 'PHP' started by Om ji Kesharwani, Dec 30, 2010.

  1. #1
    $result=mysql_query("SELECT a.*,b.* FROM signup_form a JOIN user_relationships b ON a.id = b.friend_id");

    while($row=mysql_fetch_array($result))
    {
    echo $row['f_name']." ".$row['f_name']."<br/>";
    }


    Problem is both the table is having f_name column but the value is different and when i fetch the record it shows only the value from left table .

    echo $row['f_name']." ".$row['f_name']."<br/>";

    How to differentiate the the above two values?
     
    Om ji Kesharwani, Dec 30, 2010 IP
  2. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Use aliases like

    SELECT a.f_name AS first_f_name, b.f_name AS second_f_name ... etc
     
    drctaccess, Dec 30, 2010 IP