表为单独表,树结构 layer共有4层, 此sql为通过id list 查询出 layer = 2 的 id 个数 id , parent_id, layer SELECT COUNT(DISTINCT ID) AS countFROM ( SELECT DISTINCT parent_geography_id AS ID FROM core_master_db.geography WHERE ( geography_id IN (49887, 49888, 49886, 1775, 1) OR…
在工作中写了人生的第一个查询语句,虽然是在原有基础上改的,但仍然学到了不少知识 代码: select distinct m.id, (select z.jianc from model_zuzjg z where z.id=m.huoz_id) as huoz, (select mingc from model_pinz where id=m.meiz_id) as meiz, ifnull((select kc.shul from yw_kuczt kc where kc.meiduo_id=…