我是靠谱客的博主 朴实鸭子,这篇文章主要介绍mysql中为同一张表取多个别名&为某一列取别名,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
select employee1.name as employee from employee employee1,employee employee2 where employee1.managerId=employee2.id and employee1.salary>employee2.salary;

这里给同一张表取别名的方法是,

select 列名 as 新列名 from 表名 新表名1,表名 新表名2;

 

如果name重复出现,想要在多个name中只保留一个,则在表名前面加distinct;

复制代码
1
2
3
select distinct employee1.salary as employee from employeer employee1,employeer employee2 where employee1.id!=employee2.id and employee1.salary=employee2.salary ;

 

最后

以上就是朴实鸭子最近收集整理的关于mysql中为同一张表取多个别名&为某一列取别名的全部内容,更多相关mysql中为同一张表取多个别名&为某一列取别名内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(112)

评论列表共有 0 条评论

立即
投稿
返回
顶部