zoukankan      html  css  js  c++  java
  • 根据parentID更新path和idpath

    CREATE TABLE `category` (
      `category_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '类目编号',
      `category_group_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '类目组编号',
      `category_name` varchar(64) NOT NULL DEFAULT '' COMMENT '类目名称',
      `path` varchar(64) NOT NULL DEFAULT '' COMMENT '完整路径',
      `idpath` varchar(64) NOT NULL DEFAULT '' COMMENT '完整路径ID',
      `publish_flag` char(1) NOT NULL DEFAULT '0' COMMENT '是否发布 0否、1是',
      `spell` varchar(64) NOT NULL DEFAULT '' COMMENT '简拼',
      `brand_flag` char(1) NOT NULL DEFAULT '0' COMMENT '是否品牌 0否、1是',
      `leaf_flag` char(1) NOT NULL DEFAULT '0' COMMENT '是否包含子集 0否、1是',
      `tips` varchar(64) NOT NULL DEFAULT '' COMMENT '提示',
      `parent_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父ID',
      `category_other_property` varchar(2000) NOT NULL DEFAULT '' COMMENT '附加属性',
      `revision` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '乐观锁',
      `create_by` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建人',
      `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
      `update_by` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新人',
      `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
      `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删、1已删',
      PRIMARY KEY (`category_id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=137 DEFAULT CHARSET=utf8mb4 COMMENT='类目 ';
    
    update CATEGORY c join (SELECT concat(a.PATH,'|',b.category_name) path1,b.category_id, concat(B.parent_id,'|',B.category_id)  ID
    FROM CATEGORY A, CATEGORY B WHERE A.category_id = B.parent_id and b.parent_id != '0') a1
    set c.path = a1.path1 ,C.idpath = a1.ID
    where parent_id != '0'
  • 相关阅读:
    使用CSVDE批量导入命令/出口AD用户
    Everything You Wanted to Know About Machine Learning
    android Vibrator 用法
    oc-25- @property @synthesize
    oc-24-点语法
    oc-23-static
    oc-22-sel
    oc-21-class对象
    oc-20-多态
    oc-19-成员变量修饰符
  • 原文地址:https://www.cnblogs.com/fangts/p/12304764.html
Copyright © 2011-2022 走看看