tags:

views:

86

answers:

3

I want to be able to select the column from users and dusers. example:

select u.user, d.user FROM users u JOIN dusers .... etc.

...like so:

echo $row['u.user']

echo $row['d.user']

I tried this, but no go. How do I specify what table to retrieve the user from?

+1  A: 

Alias the columns in the select clause:

select u.user AS u_user, d.user AS d_user ....

then you can use:

echo $row['u_user']  
echo $row['d_user']
Josh Hinman
HAH! I had tried that earlier... but the field I tried it on happened to have no data in it so I thought it didn't work. Thanks
payling
+1  A: 
SELECT
    u.user AS u_user,
    d.user AS d_user
FROM users u JOIN dusers

Then:

echo $row['u_user'];
echo $row['d_user'];
Ionuț G. Stan
+1  A: 

Use the "AS" sql attribute.

select u.user AS uuser, d.user AS duser FROM users u JOIN dusers ...

And the array will be the following :

echo $row['uuser']
echo $row['duser']
Damien MATHIEU