I have a table in which I want to retrieve the table as follow.

Login Name Parent User Email ID Mobile No
abc abc_parent abc@abc.com 9999999999

MySql Table as follow in tbl_users

user_id parent_user loginname email mobile
321 123 abc_parent abc@abc.com 9999999999
231 456 abc 123@123.com 8888888888

I am having issue as mentioned on the top, I am not able to retrieve the data for parent user as abc_parent, am able to achieve to get parent user id not the parent user loginname as all loginnames come in single column and ids come in first 2 columns.

How can I show the parent user loginname in place of parent_user id.

Currently, i use the following code.

SELECT * FROM tbl_users where status_id='2'

any help will be appreciated, thanks

6 Years
Discussion Span
Last Post by peter_carlos

Try this

SELECT user_id,parent_user,loginname,email,mobile
FROM tbl_users t1 where t1.status_id='2'
inner join tbl_users t2
on t2.user_id=t1.parent_user

hope it works

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.