declare @table1 table ([id] int, [name] varchar(50))
insert @table1 select 1,'a' union all select 2,'a' union all select 1,'b'
select * from @table1
问题1: select 1 from @table1 和 select 1 区别在于什么?
问题2: 为什么 from @table1 就会出现 和@table1表一样行数的1 的值?
问题3: select 关键字 具体什么意思,FROM 关键字具体什么意思?
问题4: select count(name) from @table1 where id = 1 group by name order by name desc 这句SQL 执行顺序是怎样的,不太能非常明白~
希望哪位大哥 能 详细 阐述 这些 语句中 执行的一般顺序 和规律,我哪是不太能分清楚先执行哪部分,再根据那部分得结果。
insert @table1 select 1,'a' union all select 2,'a' union all select 1,'b'
select * from @table1
问题1: select 1 from @table1 和 select 1 区别在于什么?
问题2: 为什么 from @table1 就会出现 和@table1表一样行数的1 的值?
问题3: select 关键字 具体什么意思,FROM 关键字具体什么意思?
问题4: select count(name) from @table1 where id = 1 group by name order by name desc 这句SQL 执行顺序是怎样的,不太能非常明白~
希望哪位大哥 能 详细 阐述 这些 语句中 执行的一般顺序 和规律,我哪是不太能分清楚先执行哪部分,再根据那部分得结果。
高手 赐教, 小弟 初学~
select 1显示一个常量;
select 1 from @table1显示N行1,N为@table1的行数。问题2: 为什么 from @table1 就会出现 和@table1表一样行数的1 的值?
因为它要搜索每一行。问题3: select 关键字 具体什么意思,FROM 关键字具体什么意思?
SELECT表示选择输出什么,FROM表示从哪里搜索数据。问题4: select count(name) from @table1 where id = 1 group by name order by name desc 这句SQL 执行顺序是怎样的
1、from @table1 where id = 1
2、order by name desc
3、group by name
4、count(name)
5、select