How do I write an SQL query to find out which employees are from a single location where employee and location are different table.
如何编写SQL查询以查找哪些员工来自员工和位置不同的单个位置。
select count(*) from employee;
The above gives only the count of employees but I need to display their name and location
以上只给出了员工的数量,但我需要显示他们的姓名和位置
1 个解决方案
#1
0
COUNT
will obviously give you only the count of the number of employees.
COUNT显然只会给你员工人数。
For specific columns such as 'name' and 'location', just do:
对于“名称”和“位置”等特定列,只需执行以下操作:
SELECT e.name, l.location
FROM employee e
JOIN location l ON e.location_id = l.location_id
(or JOIN on whatever is the common association column between the employee
and location
table)
(或者在员工和位置表之间的公共关联列上加入)
#1
0
COUNT
will obviously give you only the count of the number of employees.
COUNT显然只会给你员工人数。
For specific columns such as 'name' and 'location', just do:
对于“名称”和“位置”等特定列,只需执行以下操作:
SELECT e.name, l.location
FROM employee e
JOIN location l ON e.location_id = l.location_id
(or JOIN on whatever is the common association column between the employee
and location
table)
(或者在员工和位置表之间的公共关联列上加入)