• mysql自关联插入数据-级联地区


    DROP TABLE IF EXISTS `booktest_areainfo`;
    
    CREATE TABLE `booktest_areainfo` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `title` varchar(20) COLLATE utf8_bin NOT NULL,
      `parea_id` int(11) DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `booktest_areai_parea_id_4c4f198f54b858a0_fk_booktest_areainfo_id` (`parea_id`),
      CONSTRAINT `booktest_areai_parea_id_4c4f198f54b858a0_fk_booktest_areainfo_id` FOREIGN KEY (`parea_id`) REFERENCES `booktest_areainfo` (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

    插入数据:、

    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610000',        '陕西省',        NULL);
    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610100',        '西安市',        '610000');
    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610101',        '市辖区',        '610100');
    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610102',        '新城区',        '610100');
    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610103',        '碑林区',        '610100');
    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610200',        '铜川市',        '610000');
    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610222',        '铜川市',        '610200');
    INSERT INTO `test5`.`booktest_areainfo` VALUES ('610204',        '耀州区',        '610200');
  • 相关阅读:
    原码, 反码, 补码 详解
    位移运算符
    ASP.NET中httpmodules与httphandlers全解析
    MySQL count
    真正的能理解CSS中的line-height,height与line-height
    IfcEvent
    IfcWorkCalendarTypeEnum
    IfcSingleProjectInstance
    转换模型
    IfcTypeProduct
  • 原文地址:https://www.cnblogs.com/huodaihao/p/8290338.html
Copyright © 2020-2023  润新知