我的sql更新语句在eclipse里报附近有语法错误,但是我把sql语句复制到sqlserver 2005里去试却是正常的,能更新。请问这是什么原因。这是更新语句ps=conn.prepareStatement(
"update Bbs_Post set PostLastBackUserId=(select top 1 AssId from tbl_Assistant,Bbs_PostBack where" +
"tbl_Assistant.UserName=Bbs_PostBack.PostBackSender and PostBackSender=" +
"(select top 1 PostBackSender from Bbs_PostBack,Bbs_Post" +
"where Bbs_PostBack.PostBackPostId=Bbs_Post.PostId and PostId="+id
+"order by PostBackId desc)order by PostBackId desc)where PostId="+id);
"update Bbs_Post set PostLastBackUserId=(select top 1 AssId from tbl_Assistant,Bbs_PostBack where" +
"tbl_Assistant.UserName=Bbs_PostBack.PostBackSender and PostBackSender=" +
"(select top 1 PostBackSender from Bbs_PostBack,Bbs_Post" +
"where Bbs_PostBack.PostBackPostId=Bbs_Post.PostId and PostId="+id
+"order by PostBackId desc)order by PostBackId desc)where PostId="+id);
"update Bbs_Post set PostLastBackUserId=(select top 1 AssId from tbl_Assistant,Bbs_PostBack where " +
"tbl_Assistant.UserName=Bbs_PostBack.PostBackSender and PostBackSender= " +
"(select top 1 PostBackSender from Bbs_PostBack,Bbs_Post " +
"where Bbs_PostBack.PostBackPostId=Bbs_Post.PostId and PostId="+id
+"order by PostBackId desc)order by PostBackId desc)where PostId="+id);拼接的时候注意where后面的空格
楼主可以把拼出来的sql 用System.out.println()输出到控制台然后粘到查询分析器里执行一下就看出来了
System.out.println(sql);
你就会发现错误的地方了.