数据库中有三张表
user表
id username password
1 zhangsan 11111
2 lisi 11111list表
id uid name
1 1 lisi
2 1 wangwu
3 2 zhangsannote表
id uid title
1 1 maidongxi
2 1 haoren
3 1 xiao
4 2 haha
list表和note的uid是通过user的id外键关联
我想使用HibernateTeplate.find的方法查询出
user表中的用户在list表中和note表中拥有多少条记录
例如
uid list note
1 2 3
2 1 1
相当于SQL中的
select a.uid,
(select count(uid) from list where uid = a.uid)as list,
(select count(uid) from note where uid = a.uid)as note
from list a 这个查询语句
求各位大侠帮帮忙啊
user表
id username password
1 zhangsan 11111
2 lisi 11111list表
id uid name
1 1 lisi
2 1 wangwu
3 2 zhangsannote表
id uid title
1 1 maidongxi
2 1 haoren
3 1 xiao
4 2 haha
list表和note的uid是通过user的id外键关联
我想使用HibernateTeplate.find的方法查询出
user表中的用户在list表中和note表中拥有多少条记录
例如
uid list note
1 2 3
2 1 1
相当于SQL中的
select a.uid,
(select count(uid) from list where uid = a.uid)as list,
(select count(uid) from note where uid = a.uid)as note
from list a 这个查询语句
求各位大侠帮帮忙啊
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货