国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

java - 數據庫查詢多表

瀏覽:114日期:2022-06-13 11:46:39

問題描述

前提 oralce,mybatis現在有多張表 我現在需要統計每張表里面的信息的數量,也就是count(*)

我現在的方法是寫了多個方法 比如 mapper里:long selectCountA;long selectCountB;long selectCountC;

這樣的話,我要去數據庫里查三次。分別獲得3個數據我想能不能 寫一句sql語句 直接獲得三個值

求解?

。能給我一個oracle語句的嗎, 咋都是mysql。。

問題解答

回答1:

select 'a' name, count(1)from tableAunionselect 'b' name, count(1)from tableBunionselect 'C' name, count(1)from tableC

采用多列的寫法

with temp_a as (select count(*) num from talbeA),temp_b as (select count(*) num from tableB),temp_c as (select count(*) num from tableC)select temp_a.num, temp_b.num, temp_c.num from dual;回答2:

select A.countA,B.countB from (select count(*) as countA from t_countA) as A ,(select count(*) as countB from t_countB) as B

這樣?

回答3:

Mysqljava - 數據庫查詢多表

Oracle在以上語句后面加 from dual

回答4:

Mysql的select table_rows from information_schema.TABLES where table_schema in (’schema1’,’schema2’,’scheman’) and table_name in (’tableName1’,’tableName2’,’tableNameN’)相信 oralce也有類似的系統表

相關文章:
主站蜘蛛池模板: 保定市| 六安市| 马鞍山市| 思南县| 新巴尔虎右旗| 田林县| 鹰潭市| 云南省| 措勤县| 微博| 阳朔县| 峨山| 广元市| 乌鲁木齐市| 哈巴河县| 二连浩特市| 巫溪县| 云南省| 离岛区| 东兰县| 桦甸市| 肥东县| 宝清县| 黑龙江省| 永修县| 通道| 香格里拉县| 中卫市| 达州市| 无锡市| 双江| 大埔县| 宁晋县| 资兴市| 衡水市| 罗山县| 多伦县| 连城县| 淮阳县| 内江市| 蒙山县|