SELECT * FROM (SELECT COUNT(1) AS num,'data' AS tablename FROM data WHERE gid = '1' UNION ALL SELECT COUNT(1) AS num,'data_1' AS tablename FROM data_1 WHERE gid = '1') temp
mysql的库,如果数据量比较大,效率会高么? 还有,最有那个a是啥意思呀? 还有别的写法么?谢谢
SQL select (select count(id) from data where gid='1') as a,(select count(id) from data1 where gid='1') as b ACCESS select count(id) as num, (select count(id) from data1 where gid='1') as num1 from data where gid='1'
不好意思,看错你的意思了select sum(num1) as num1,sum(num2) as num2 from ( select count(*) as num1,num2=0 from #data where gid=1 union all select num1=0,count(*) as num2 from #data_1 where gid=1) a
FROM (SELECT COUNT(1) AS num,'data' AS tablename
FROM data
WHERE gid = '1'
UNION ALL
SELECT COUNT(1) AS num,'data_1' AS tablename
FROM data_1
WHERE gid = '1') temp
还有,最有那个a是啥意思呀?
还有别的写法么?谢谢
SQL
select (select count(id) from data where gid='1') as a,(select count(id) from data1 where gid='1') as b
ACCESS
select count(id) as num, (select count(id) from data1 where gid='1') as num1 from data where gid='1'
select count(*) as num1,num2=0 from #data where gid=1 union all
select num1=0,count(*) as num2 from #data_1 where gid=1) a
sum(num1) as num1,sum(num2) as num2 ??