免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1090 | 回复: 0
打印 上一主题 下一主题

mysql怎么关联排序 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-06-03 17:23 |只看该作者 |倒序浏览
三张表   
A表 id,userID,date,money   
B表 id,userID,date,money   
C表 id,userID,date,money   
   
查询三张表的记录 userID = userID = userID = ‘某一个值’ 而且 根据date排序   
   
在ibatis框架的配置文件中怎么写?  

解答:
  1. <select id="select1" parameterClass="string" resultClass="com.test.Bean">  
  2.    select * from (  
  3.        select  
  4.          t1.id,t1.userId,t1.date,t1.money  
  5.        from  
  6.          A t1  
  7.        where  
  8.          t1.id = #value#  
  9.        union all  
  10.        select  
  11.          t1.id,t1.userId,t1.date,t1.money  
  12.        from  
  13.          B t1  
  14.        where  
  15.          t1.id = #value#  
  16.        union all  
  17.        select  
  18.          t1.id,t1.userId,t1.date,t1.money  
  19.        from  
  20.          C t1  
  21.        where  
  22.          t1.id = #value#  
  23.    ) m  
  24.    order by m.date  
  25. </select>
复制代码
转自:http://bbs.ibeifeng.com/read-htm-tid-65928.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP