一个奇怪的SQL语句
select * FROM JXCOUTSTORAGE A, JXCOUTSTORAGELIST B,JXCStorage C,CWOnlyCarCalculateFeeTbl D, WXOPERATEREPORTREPAIRTBL E
WHERE A.OUTSTORAGEID* = B.OUTSTORAGEID and B.STORAGEID*=C.STORAGEID and A.WorkNo*=D.WorkNo and a.workno* = e.workcodeing
[解决办法]
这样试试
select * FROM JXCOUTSTORAGE ALEFT JOIN JXCOUTSTORAGELIST B ON A.OUTSTORAGEID = B.OUTSTORAGEID LEFT JOIN JXCStorage C ON B.STORAGEID=C.STORAGEILEFT JOIN CWOnlyCarCalculateFeeTbl D ON A.WorkNo=D.WorkNoLEFT JOIN WXOPERATEREPORTREPAIRTBL E ON a.workno= e.workcodeing
[解决办法]
用* = 多条件时结果集是容易出错
楼主是SQL2000?这是SQL新版本废弃的功能
[解决办法]
MS SQL SERVER 支持两种形式表间连接①从Sybase继承来的形式:字段1 *= 字段2 (左连接)字段1 =* 字段2 (右连接)没有这种形式的全外连接语法②标准的外连接语法left [outer] join on 逻辑表达式 right [outer] join on 逻辑表达式full [outer] join (全外连接) on 逻辑表达式
[解决办法]
2000版本以上的直接用连接或自然连接.就可以了
select *
FROM JXCOUTSTORAGE A
LEFT JOIN JXCOUTSTORAGELIST B ON A.OUTSTORAGEID = B.OUTSTORAGEID
LEFT JOIN JXCStorage C ON B.STORAGEID=C.STORAGEI
LEFT JOIN CWOnlyCarCalculateFeeTbl D ON A.WorkNo=D.WorkNo
LEFT JOIN WXOPERATEREPORTREPAIRTBL E ON a.workno= e.workcodeing
版主的