日期:2014-05-16  浏览次数:21000 次

这个SQL命令,难道不可以这么写吗?错哪了?
如下命令时,正常运行
Recordset_ZhaGong_PiZhuen_cmd.CommandText = "SELECT * FROM dbo.ZhaGongGongShi where (shengheid1 is not null and pizhuengid is null and Gongshi_ty<>'来料不良损失' and Gongshi_ty <> '停工待料补贴') or (shengheid1 is not null and pizhuengid is null and Gongshi_ty='来料不良损失' and jiandingid is not null ) or (shengheid1 is not null and pizhuengid is null and Gongshi_ty='停工待料补贴' and jiandingid is not null) order by id " 

如下命令时,则不能正常运行,出错.(红色的部分,是增加的命令)
Recordset_ZhaGong_PiZhuen_cmd.CommandText = "select A.*
,B.dep_mess as 部门名称,
C.dep_code as 部门编码,
L.employeeid as 职员编码,
M.name as 职员姓名,
N.sex as 性别,
O.id_number as 身份证号,
P.user_name as 制单人姓名,
Q.user_name as 审核人姓名,
R.user_name as 鉴定人姓名, 
S.user_name as 公司审核人
 
FROM ZhaGongGongShi 
LEFT JOIN department B ON A.depid=B.dep_id 
LEFT JOIN department C ON A.depid=C.dep_id 
LEFT JOIN employee L ON A.zhiyuanid=L.id 
LEFT JOIN employee M ON A.zhiyuanid=M.id 
LEFT JOIN employee N ON A.zhiyuanid=N.id 
LEFT JOIN employee O ON A.zhiyuanid=O.id 
LEFT JOIN user_password P ON A.zhidanid=P.user_id 
LEFT JOIN user_password Q ON A.shengheid=Q.user_id 
LEFT JOIN user_password R ON A.jiandingid=R.user_id 
LEFT JOIN user_password S ON A.shengheid1=S.user_id
 
WHERE (shengheid1 is not null and pizhuengid is null and Gongshi_ty<>'来料不良损失' and Gongshi_ty <> '停工待料补贴') or (shengheid1 is not null and pizhuengid is null and Gongshi_ty='来料不良损失' and jiandingid is not null ) or (shengheid1 is not null and pizhuengid is null and Gongshi_ty='停工待料补贴' and jiandingid is not null) order by A.id" 

------解决方案--------------------
换行的?换行的不行哦,换行的用连接符