0
我有以下查詢在SQLSERVER聯接條件引用傳遞別名,但是當我通過這個別名的列名的引用名稱它顯示無效的列名我怎麼能做到這一點我們可以在
select OM.*,
convert(int,Replace(Ltrim(Replace(left(OM.mstrefc,6), '0', ' ')), ' ', '0')) as partycode,
OI.*,
Ac.AcctName,
Ac.acctaddr,
UN.UnitName
from ordemst OM
join ordeitd OI
on OM.mstCode = OI.ItdCode
join Account Ac
on OM.partycode = Ac.acctcode
left join unitdet UN
on OI.ItdUnit = UN.unitcode and
OI.CompCode = UN.CompCode
where OM.MstCode = 47 and
OM.MstType =79 and
OM.CompCode =117 and
AC.compcode =117 and
OI.Compcode=117
聯接子句中不能使用別名從SELECT子句。 –