手工写的:
select l.strLotNo,l.strLotName,l.strDescription,l.lngCatalogID,b.strCatalogBig,l.lngCatalogIDSnd,s.strCatalogSnd,l.lngMaterialID,m.strMaterial,l.strSize,l.strSUnit,l.dblWeight,l.strWUnit,l.dblPrice,l.strPUnit,l.dblClosingCost,l.strcpunit,l.dblStock,l.lngAuthorID,a.strAuthor,l.dtmObjCreated,l.strPrize,l.dtmRsCreated,l.strRemarks from tblLot as l left join vCatBig as b on (tblLot.strLotNo=vCatBig.Bstrlotno and tblLot.lngCatalogID=vCatBig.Blngcatalogid) left join vCatSnd as s on (tblLot.strLotNo=vCatSnd.Sstrlotno and tblLot.lngCatalogID=vCatSnd.slngcatalogid) left join tblMaterial as m on (tblLot.lngMaterialID=tblMaterial.lngMaterialID) left join tblAuthor as a on (tblLot.lngAuthorID = tblAuthor.lngAuthorID) where tblLot.strStatus<>'Void'
老是执行不过。再分小一点:
select l.strLotNo,b.catalogBig from tblLot as l join vCatBig as b on tblLot.strLotNo=vCatBig.strlotno and tblLot.lngCatalogID=vCatBig.lngcatalogid where tblLot.strStatus<>'Void'还是不行。 select strLotNo,strLotName,lngCatalogID,strCatalogBig from tblLot as l join vCatBig as b on (l.strLotno=b.bstrLotNo )
结果可以运行了。
------------------
现在知道如果表有别名: as l 和 as b 关联字段要写明 l 或者 b ,不可以用原表名。
还有select 字段如果要选择两个表以上的字段,最好在每个字段前加上标的别名,如上面的
l.strLotNo,s.strCatalogSnd CREATE VIEW [vLot] AS select l.strLotNo,l.strRemarks from tblLot as l left join vCatBig as b on (l.strLotNo=b.Bstrlotno and l.lngCatalogID=b.Blngcatalogid) left join vCatSnd as s on (l.strLotNo=s.Sstrlotno and l.lngCatalogID=s.slngcatalogid) left join tblMaterial as m on (l.lngMaterialID=m.lngMaterialID) left join tblAuthor as a on (l.lngAuthorID = a.lngAuthorID) where l.strStatus<>'Void' 原文链接:https://www.f2er.com/vb/260806.html