pep小学英语说课稿
mysql左连查询弊端_mysql左连接查询结果不准确
现有四张表
表(1)res_resource_catalog
表(2)res_catalog_classify
表(3)res_resource_classify
表(4)res_resource_mount
其中,表3是表1和表2的中间表,表1的主键是表4的外键
现在要统计表2中某⼀类型的表1的当前⽤户创建的数据量,以及表1相关的表4的数据量
父亲节快乐英文
⼀开始的sql如下:
SELECT rcc.id, rcc.catalog_name, COUNT(DISTINCT rrc.id) AS resourceCatalogCount,COUNT(DISTINCT rrm.id) AS resourceCount FROM
高铁英文(SELECT * FROM res_catalog_classify WHERE catalog_type = #{catalogType} AND parent_id != '0' AND is_publish = 1) rcc
LEFT JOIN res_resource_classify rrc ON rcc.id = rrc.classify_id
LEFT JOIN res_resource_catalog rrc1 source_id = rrc1.id
LEFT JOIN res_resource_mount rrm source_id = source_id
英语手抄报版面设计
ate_ur = #{createUr}AND rrc1.is_publish = 1GROUP BY rcc.id
mania结果查询不准确,当createUr没有在表1中创建数据时,查询结果为null,实际应该是表2数据有,但是结果中的resourceCatalogCount为0,经改正后的sql如下:
史记翻译SELECT rcc.id, rcc.catalog_name, COUNT(DISTINCT rrc1.id) AS resourceCatalogCount,COUNT(DISTINCT rrm.id) AS resourceCount FROM
吸血鬼日记第二季10
(SELECT * FROM res_catalog_classify WHERE catalog_type = #{catalogType} AND parent_id != '0' AND is_publish = 1) rcc
LEFT JOIN res_resource_classify rrc ON rcc.id = rrc.classify_id
怎么化妆好看
LEFT JOIN (fprintf
SELECT * FROM res_resource_catalog
ate_ur = #{createUr}AND rrc1.is_publish = 1) rrc1 source_id = rrc1.id
LEFT JOIN res_resource_mount rrm source_id = source_id
英语六级考试2021考试时间
GROUP BY rcc.id