十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
*select
创新互联公司专注于企业成都营销网站建设、网站重做改版、烟台网站定制设计、自适应品牌网站建设、HTML5建站、商城开发、集团公司官网建设、成都外贸网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为烟台等各大城市提供网站开发制作服务。
[列名]
from
Students
as
s
inner
join
专业Name
as
z
on
s.[学员编号]=z.[学员编号]
inner
join
分数Name
as
f
on
......同前
where
z.[专业名]
like
'%1%'
select
[列名]
from
Students
as
s
inner
join
专业Name
as
z
on
s.[学员编号]=z.[学员编号]
inner
join
分数Name
as
f
on
......同前
where
z.[专业名]
like
'%1%'
and
z.name
like
'%2%'
and
f.name
like
'%2%'
.....同前
应该没有理解错误吧呵呵!
后台可以写一个循环的查询语句,比如for(int i=1;i13;i++),把这个i作为一个参数添加到sql语句中,这样就能控制一个循环查询12张表,同时在循环里把查询的结果放到一个list里面这样就能把12张表的所有结果传给前台处理。还有不懂的可以追问,望采纳
既然三个表都是有关联的,先单表统计
,再合起来统计。。
select
A.*,BC.sum_B,BC.sum_C
from
A表
as
A
join
(
select
单位编码,sum_B,sum_C
from
(select
单位编码,sum(数据B)
as
sum_B
from
B表
group
by
单位编码)
as
B
join
(select
单位编码,sum(数据C)
as
sum_C
from
C表
group
by
单位编码)
as
C
on
B.单位编码=C.单位编码
)
as
BC
on
A.单位编码=BC.单位编码
简化下:
select
A.*,B.sum_B,C.sum_C
from
A表
as
A
join
(select
单位编码,sum(数据B)
as
sum_B
from
B表
group
by
单位编码)
as
B
on
A.单位编码=B.单位编码
join
(select
单位编码,sum(数据C)
as
sum_C
from
C表
group
by
单位编码)
as
C
on
A.单位编码=C.单位编码
select a.*,b.remark,c.content from a,b,c where patindex('%'+convert(varchar,b.id)+'%',a.fb)0
or patindex('%'+convert(varchar,c.id)+'%',a.fb)0
select 主表名.pcode, count(从表名.pcode)
from 主表名, 从表名
where 主表名.pcode=从表名.pcode
group by 主表名.pcode