简体   繁体   中英

Get values from join query

I have two tables: user and details table. I want to display the details table in a table format.

user table Structure is:

在此处输入图片说明

details Table Structure is:

在此处输入图片说明

Result table Structure is:
在此处输入图片说明

I have tried this query:

SELECT A.*,B.name,C.name as Interviewer 
FROM exitdetail_hrms A
  LEFT JOIN hh_tbl_user B ON A.emp_id=B.sno 
  JOIN hh_tbl_user C
WHERE A.emp_id='12' AND C.sno='13' 

But I didn't get exact answer..kindly help me on this..

Thanking You..

I am not sure, because you table description does not match the SQL you used, but i think the following SQL should solve your problem:

SELECT A.*,B.name,C.name as Interviewer 
FROM exitdetail_hrms A
  LEFT JOIN hh_tbl_user B ON A.emp_id=B.s_no 
  LEFT JOIN hh_tbl_user C ON A.interviewed = C.s_no
WHERE A.emp_id='12' AND C.sno='13' 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM