当前位置:首页 > 开发 > 数据库 > 正文

sql查地区省市县

发表于: 2015-01-15   作者:3213213333332132   来源:转载   浏览:
摘要: -- db_yhm_city SELECT * FROM db_yhm_city WHERE class_parent_id = 1 -- 海南 class_id = 9 港、奥、台 class_id = 33、34、35 SELECT * FROM db_yhm_city WHERE class_parent_id =169 SELECT d1.cla
-- db_yhm_city   
SELECT * FROM db_yhm_city WHERE class_parent_id = 1 -- 海南 class_id = 9 港、奥、台 class_id = 33、34、35   
  
SELECT * FROM db_yhm_city WHERE class_parent_id =169   
  
SELECT d1.class_name, d2.class_name, d3.class_name FROM db_yhm_city d1    
RIGHT JOIN db_yhm_city d2 ON d1.class_id = d2.class_parent_id    
RIGHT JOIN db_yhm_city d3 ON d2.class_id = d3.class_parent_id   
WHERE d3.class_id = 1445   
  
-- tb1_publicarea   
SELECT * FROM tbl_publicarea WHERE parentid = 0 -- 海南 areaid = 21   
  
SELECT * FROM tbl_publicarea WHERE parentid = 21   
  
SELECT t1.areaname, t2.areaname, t3.areaname FROM tbl_publicarea t1    
RIGHT JOIN tbl_publicarea t2 ON t1.areaid = t2.parentid    
RIGHT JOIN tbl_publicarea t3 ON t2.areaid = t3.parentid    
WHERE t3.areaid = 264   
  
-- t_area   
SELECT * FROM t_area WHERE parentid IS NULL -- 海南 id = 460000   
  
SELECT * FROM t_area WHERE parentid = 460000  -- 省直辖 id = 469000   
  
SELECT * FROM t_area WHERE parentid = 469000   
  
SELECT a1.name, a2.name, a3.name FROM t_area a1    
RIGHT JOIN t_area a2 ON a1.id = a2.parentid    
RIGHT JOIN t_area a3 ON a2.id = a3.parentid    
WHERE a3.id = 419001   
  
SELECT * FROM t_area WHERE NAME LIKE "%省直辖%"  
  
SELECT * FROM t_area WHERE id = 419000 -- 省直辖  

sql查地区省市县

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号