• 通过现有数据导出新表SQL


    Date: 20140217

    Auth: JIN

    需求: 导出一个表的两个列的表的SQL语句(包含数据)

    方法:创立一个临时表

    mysql> desc kw_keywords;
    +------------+------------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +------------+------------------+------+-----+---------+----------------+
    | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
    | keyword | varchar(100) | YES | MUL | | |
    | cat_id | int(1) unsigned | YES | | NULL | |
    | search_num | int(10) unsigned | YES | | NULL | |
    | priority | int(10) unsigned | YES | | NULL | |
    | is_embody | int(1) | YES | | NULL | |
    | url | varchar(256) | YES | | | |
    | remark | varchar(100) | YES | | | |
    | type | int(11) | YES | | NULL | |
    | addtime | datetime | YES | | NULL | |
    | updatetime | datetime | YES | | NULL | |
    +------------+------------------+------+-----+---------+----------------+
    11 rows in set (0.00 sec

    确认数据需要的数据
    select keyword,url from kw_keywords where remark='人工筛选';

    创建指定列的表
    create table tb_word select keyword,url from kw_keywords where remark='人工筛选';

    create table tb_word select keyword as word,url from kw_keywords where date_format(addtime,'%Y-%m-%d') in ('2014-02-25', '2014-02-28');

    确认
    mysql> select * from tb_word limit 10;

    导出
    # mysqldump -S /data/mysql/3310/mysql.sock -ppwd keyword tb_word > tb_word_20140217.sql

  • 相关阅读:
    如何实现浏览器内多个标签页之间的通信?
    vue组件库的基本开发步骤(源代码)
    vue组件库的基本开发步骤
    Websocket原理
    TCP和UDP的区别
    一句话概括 tcp三次握手
    简单说一下你对http和https的理解
    .Ajax(async异步与sync同步)
    get和post请求方式的区别
    面试易忽略状态码
  • 原文地址:https://www.cnblogs.com/diege/p/3552616.html
Copyright © 2020-2023  润新知