zoukankan      html  css  js  c++  java
  • 辅助

    "select result.*,content.* from he_history_result result join he_history_content content on content.history_id = result.id " 
    "where result.create_time between date 00:00:00 and date 23:59:59 order by content.create_time limit 1"


    select result.*,content.* from he_history_result result join he_history_content content on content.history_id = result.id where result.create_time between '2020-03-29 00:00::00' and '2020-03-29 23:59:59' order by content.create_time limit 1;

    # 失败
    select result.*,content.* from he_history_result result left join he_history_content content on result.id = (select content_in.history_id from he_history_content content_in where content_in.history_id = result.id order by content_in.create_time DESC limit 1) where result.create_time between '2020-03-29 00:00::00' and '2020-03-29 23:59:59';


    # 成功
    select result.*,content.* from he_history_result result left join he_history_content content on content.id = (select content_in.id from he_history_content content_in where content_in.history_id = result.id order by content_in.create_time DESC limit 1) where result.create_time between '2020-03-29 00:00::00' and '2020-03-29 23:59:59';

    # 改造
    select result.id as result_id,result.create_time as call_start_time,content.create_time as call_end_time,result.agent_id as agent_id,result.caller_id as caller_id,result.called_id as called_id,result.channel_id as channel_id from he_history_result result left join he_history_content content on content.id = (select content_in.id from he_history_content content_in where content_in.history_id = result.id order by content_in.create_time DESC limit 1) where result.create_time between '2020-03-29 00:00:00' and '2020-03-29 23:59:59';


    实时建表语句
    mysql> show create table he_history_result;
    +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table             | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
    +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | he_history_result | CREATE TABLE `he_history_result` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `create_time` datetime DEFAULT NULL,
      `agent_id` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      `called_id` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      `caller_id` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      `channel_id` varchar(255) COLLATE utf8_bin NOT NULL,
      `pn` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      `poi` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      `short_vin` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      `vin` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=1802482 DEFAULT CHARSET=utf8 COLLATE=utf8_bin |
    +-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> show create table he_history_content;
    +--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table              | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
    +--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | he_history_content | CREATE TABLE `he_history_content` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `create_time` datetime DEFAULT NULL,
      `confidence` int(11) DEFAULT NULL,
      `index_num` int(11) DEFAULT NULL,
      `result_code` int(11) DEFAULT NULL,
      `role` varchar(255) COLLATE utf8_bin DEFAULT NULL,
      `sentence` text COLLATE utf8_bin,
      `history_id` int(11) DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `FK_755wl338xrm1fh8d1amspycle` (`history_id`),
      CONSTRAINT `FK_755wl338xrm1fh8d1amspycle` FOREIGN KEY (`history_id`) REFERENCES `he_history_result` (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=124915245 DEFAULT CHARSET=utf8 COLLATE=utf8_bin |
    +--------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    
    
    
    
    mysql -h 127.0.0.1 -u用户名 -p密码 --default-character-set=gb2312 -e "select * from 表名" 数据库名 > test.txt
    
    
    






  • 相关阅读:
    对同一个对象绑定多个响应事件并都执行
    IO流读取与写入文件+SQL替换更新字段脚本
    去掉所有HTML标记或取出匹配HTML标记间的文本
    CS程序启动后定时循环执行Clock_Elapsed事件Timer控件
    SQL新建登录帐户,并为新帐户建立安全帐户,并授予访问数据库的角色
    WEB服务的调用与调试
    SQL修改约束
    删除数据库的所有存储过程、主键、外键、索引等
    用SQL直接将文件内容导入数据表中
    将上传文件以二进制形式存入数据库中,并下载数据库中的二进制数据生成对应的文件
  • 原文地址:https://www.cnblogs.com/stone94/p/12599644.html
Copyright © 2011-2022 走看看