I am trying to get some rows from the same table. It\'s a user table: user has user_id
and user_parent_id
.
I need to get the user_id
Your query should work fine, but you have to use the alias parent
to show the values of the parent table like this:
select
CONCAT(user.user_fname, ' ', user.user_lname) AS 'User Name',
CONCAT(parent.user_fname, ' ', parent.user_lname) AS 'Parent Name'
from users as user
inner join users as parent on parent.user_parent_id = user.user_id
where user.user_id = $_GET[id];