sql语句问题,多表列别名问题(50分)

  • 主题发起人 greengao
  • 开始时间
G

greengao

Unregistered / Unconfirmed
GUEST, unregistred user!
sql语句
select a.id as aid,b.id as bid,aid+bid as cid
from a,b where a.id =b.id
提示错误
无效的列名 aid
无效的列名 bid
 
select a.id as aid,
b.id as bid,
a.id+b.id as cid
from a,b
where a.id =b.id
 
你理解有一点问题,语句改为:
select a.id as aid,b.id as bid,a.id+b.id as cid
from a,b where a.id=b.id
 
有问题吗?
 
我写的这条语句比较简单
如果 as aid 之前又是一条子查询我就必须用别名。
怎么解决?
 
老兄,aid可是别名,不是数据里的字段呀!!!!
怎么可能用别名当数据库字段进行查询呢?
遇到子查询可以用再加(select 字段 from 数据表 where ......)后面不写了!
如果还不行,就写成存储过程,自己去编程!
 
我kao
子查询还要查一遍的,不慢吗?
 
别名不可以在查询吗?
 
接受答案了.
 
顶部