我有 1 个查询来借助内部连接从三个表中获取记录。
table name
tbl_emp as emp
tbl_sal as sal
tbl_address as addr
fields from 3 tables
Schema:
tbl_emp - empid,name,comp_id
tbl_sal - empid - emp_type
tbl_address - emp_type
询问
SELECT emp.empid, emp.name, sal.salary, addr.address
from tbl_emp as emp
INNER JOIN tbl_sal as sal
ON emp.empid = sal.empid
INNER JOIN tbl_address as addr
ON addr.emp_type = sal.emp_type
where comp_id = '114';
结果显示:
1 abc 1000 test
1 abc 1000 test
1 abc 1000 test
1 abc 1000 test
1 abc 1000 test
2 xyz 2500 main
2 xyz 2500 main
2 xyz 2500 main
2 xyz 2500 main
2 xyz 2500 main
我想要这样的结果:
1 abc 1000 test
2 xyz 2500 main
请帮助我。