create table tb(id int)insert into tb values(10)insert into tb values(20)insert into tb values(30)insert into tb values(11)insert into tb values(12)
select * , px = (select count(1) from tb where id < t.id) + 1 from tb t order by px
这里的t.id指的是什么??
select * , px = (select count(1) from tb where id < t.id) + 1 from tb t order by px
这里的t.id指的是什么??
后一个t.id是(select * , px=... from tb t order by px)这个tb表的
t.id是指外层的(select * ,px...from tb t order by px)这里的表tb
insert into tb values(10)
insert into tb values(20)
insert into tb values(30)
insert into tb values(11)
insert into tb values(12)select * ,t.id,
px = (select count(1) from tb where id < t.id) + 1
from tb t
order by px