【新手求教】SQL SERVER 同时统计几张表,同时在一张表里显示.如何做.
【新手求教】SQL SERVER 同时统计几张表,同时在一张表里显示.怎么做..
表1 music 里面存有若干条音乐的信息
表2 video 里面存有若干条视频的信息
表3 picture 里面存有若干条图片的信息
表4 text 里面存有若干条文档的信息
想统计出各张表中有多少条记录,用下面的方式显示出来
----------------
类型 数量
----------------
music X
video X
picture X
text X
能实现吗??
我现在是用一张临时表的方法,将各张表分别count出数量,然后插入到临时表中
请问还可以用其他方法实现吗??
------解决方案--------------------
select 'music', (select count(ID) from music
union
select 'video', (select count(ID) from video
union
select 'picture', (select count(ID) from picture
union
select 'text', (select count(ID) from text
表1 music 里面存有若干条音乐的信息
表2 video 里面存有若干条视频的信息
表3 picture 里面存有若干条图片的信息
表4 text 里面存有若干条文档的信息
想统计出各张表中有多少条记录,用下面的方式显示出来
----------------
类型 数量
----------------
music X
video X
picture X
text X
能实现吗??
我现在是用一张临时表的方法,将各张表分别count出数量,然后插入到临时表中
请问还可以用其他方法实现吗??
------解决方案--------------------
select 'music', (select count(ID) from music
union
select 'video', (select count(ID) from video
union
select 'picture', (select count(ID) from picture
union
select 'text', (select count(ID) from text