使用别名引用列名

Referring to column name with alias

我想知道当我为 table 设置别名时,是否有必要在语句中引用列时为其设置别名,如果它们仅对一个 table 唯一?

例如:

where Salary > (select min(p.Salary) From Professors p inner join Departments d on p.Dept_id = d.Id where d.Dept_name = 'Art')

where Salary > (select min(Salary) From Professors p inner join Departments d on p.Dept_id = d.Id where Dept_name = 'Art')

如果薪水只存在于教授 table 而 Dept_name 只存在于部门 table,那么上述两种方法都行得通吗?谢谢

如果列名是唯一的,则不需要使用 table 名称或别名来限定它们。但是,我认为对它们进行限定是一种很好的做法。