JSP+MSSQL多表查询
selecttuoyun.tiji,yingshou.shoukuanjine,yingfu.fukuanjinefromtuoyun,yingshou,yingfuwh...
select tuoyun.tiji,yingshou.shoukuanjine,yingfu.fukuanjine from tuoyun,yingshou,yingfu where tuoyun.yewubaogaodanhao = yingshou.baogaodanhao and yingshou.baogaodanhao = yingfu.baogaodanhao
这个在查询分析器里面可以运行,但怎么改到页面里面去呢?
stringSql = "select tuoyun.yewubaogaodanhao,tiji yingshou.baogaodanhao,shoukuanjine"
+ " from tuoyun,yingshou where " + " tuoyun.yewubaogaodanhao like'%"+danhao+"%' = yingshou.baogaodanhao like'%"+danhao+"%' " ;
错在那里帮忙改下谢谢!
不行啊 报错 展开
这个在查询分析器里面可以运行,但怎么改到页面里面去呢?
stringSql = "select tuoyun.yewubaogaodanhao,tiji yingshou.baogaodanhao,shoukuanjine"
+ " from tuoyun,yingshou where " + " tuoyun.yewubaogaodanhao like'%"+danhao+"%' = yingshou.baogaodanhao like'%"+danhao+"%' " ;
错在那里帮忙改下谢谢!
不行啊 报错 展开
3个回答
展开全部
"select sum(a.jianshu)as jshj,round(sum(a.maozhong),2)as mzhj,round(sum(a.tiji),2)as tjhj,"
+ " round(sum(b.shoukuanjine),2)as shxj,round(sum(c.fukuanjine),2)as fkxj,"
+ " round((sum(b.shoukuanjine)-sum(c.fukuanjine)),2)as mlhj "
+ " from tuoyun a,"
+ "(select tidanhao,round(sum(shoukuanjine*huilv),2) shoukuanjine "
+ "from yingshou group by tidanhao ) b ,"
+ "(select tidanhao,round(sum(fukuanjine*huilv),2) fukuanjine "
+ "from yingfu group by tidanhao ) c "
+ " where a.tidanhao = b.tidanhao and b.tidanhao = c.tidanhao";
+ " round(sum(b.shoukuanjine),2)as shxj,round(sum(c.fukuanjine),2)as fkxj,"
+ " round((sum(b.shoukuanjine)-sum(c.fukuanjine)),2)as mlhj "
+ " from tuoyun a,"
+ "(select tidanhao,round(sum(shoukuanjine*huilv),2) shoukuanjine "
+ "from yingshou group by tidanhao ) b ,"
+ "(select tidanhao,round(sum(fukuanjine*huilv),2) fukuanjine "
+ "from yingfu group by tidanhao ) c "
+ " where a.tidanhao = b.tidanhao and b.tidanhao = c.tidanhao";
展开全部
stringSql = "select tuoyun.yewubaogaodanhao,tuoyun.tiji,"
+" yingshou.baogaodanhao,shoukuanjine "
+" from tuoyun,yingshou ,yingfu "
+" where tuoyun.yewubaogaodanhao = yingshou.baogaodanhao "
+" and yingshou.baogaodanhao = yingfu.baogaodanhao "
+" and tuoyun.yewubaogaodanhao like '%"+danhao+"%' "
+" and yingshou.baogaodanhao like '%"+danhao+"%'";
+" yingshou.baogaodanhao,shoukuanjine "
+" from tuoyun,yingshou ,yingfu "
+" where tuoyun.yewubaogaodanhao = yingshou.baogaodanhao "
+" and yingshou.baogaodanhao = yingfu.baogaodanhao "
+" and tuoyun.yewubaogaodanhao like '%"+danhao+"%' "
+" and yingshou.baogaodanhao like '%"+danhao+"%'";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
stringSql = "select tuoyun.yewubaogaodanhao,tiji yingshou.baogaodanhao,shoukuanjine from tuoyun,yingshou ,yingfu where tuoyun.yewubaogaodanhao = yingshou.baogaodanhao and yingshou.baogaodanhao = yingfu.baogaodanhao
and tuoyun.yewubaogaodanhao like'%"+danhao+"%' = yingshou.baogaodanhao like'%"+danhao+"%' " ;
应该是你要的。
and tuoyun.yewubaogaodanhao like'%"+danhao+"%' = yingshou.baogaodanhao like'%"+danhao+"%' " ;
应该是你要的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询