SQL内部联接查询返回两个相同的列

问题描述:

假设我有以下SQL查询:

Let's say I have the following SQL query:

SELECT *
FROM employee 
INNER JOIN department ON employee.EmpID = department.EmpID

我想问一下,为什么要得到两个 EmpID 列,以及如何才能只获得其中的一个,最好是第一列.

I wanted to ask, why I am getting two EmpID columns, and how can I get only one of those, preferably the first.

我正在使用SQL Server

I'm using SQL server

SELECT employee.EmpID, employee.name, ...
FROM employee 
INNER JOIN department ON employee.EmpID=department.EmpID

要精确并指定所需的列,而不要使用astrisk选择所有列.

Be precise and specify which columns you need instead of using the astrisk to select all columns.