如此的sql语句,求原理

yinhaichao2008 2012-01-17 10:48:15
select a.Estimated_Arrival_Date_s from (
select estimated_arrival_date Estimated_Arrival_Date_s from Is_Issues_Plan_Detail where Estimated_Arrival_Date_s='aa'
)a

如此的sql语句,求原理为什么不能用Estimated_Arrival_Date_s='aa' 只能用estimated_arrival_date=‘aa’,求原理。。。。。。。。。。。。。。。
...全文
127 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
EnForGrass 2012-01-17
  • 打赏
  • 举报
回复
UP一个。这地方都是sql高手,个人也标胶喜欢
jiangshun 2012-01-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 josy 的回复:]

跟sql的执行顺序有关

SQL code
select a.Estimated_Arrival_Date_s from (
select estimated_arrival_date Estimated_Arrival_Date_s from Is_Issues_Plan_Detail)a
where Estimated_Arrival_Date_s='aa'
[/Quote]

确实是跟sql执行顺序有关

还是建议把where条件放子查询里面吧
百年树人 2012-01-17
  • 打赏
  • 举报
回复
跟sql的执行顺序有关

select a.Estimated_Arrival_Date_s from (
select estimated_arrival_date Estimated_Arrival_Date_s from Is_Issues_Plan_Detail)a
where Estimated_Arrival_Date_s='aa'
叶子 2012-01-17
  • 打赏
  • 举报
回复

declare @T table (col varchar(1))
insert into @T
select 'a' union all
select 'b' union all
select 'c'

--order by 后面就可以用别名
select col a from @T order by a
--where后面用别名的话就需要嵌套一层
select col a from @T where a='b'
/*
Invalid column name 'a'.
*/

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧