zoukankan      html  css  js  c++  java
  • mysql笔记

      

    query_insert = "insert into pospal_kf.question (question, answer, status, createtime, updatetime) VALUES ('%s', '%s', 0,now(), now())" %(question,answer)

    %s要加引号

    UPDATE pospal_kf.similarquestion SET questionid=%d WHERE id=%d

    simi_id = int(row['相似问题ID'])
    pandas读取id会读取为float,需要转化成Int

    答案需要strip掉后面的换行
    answer = row['答案'].strip()

    SELECT * FROM pospal_kf.similarquestion WHERE question like '%会员充值要怎么操作%';
    SELECT * FROM pospal_kf.question WHERE id= (SELECT questionid FROM pospal_kf.similarquestion WHERE question like '%会员充值要怎么操作%')

    INSERT INTO pospal_kf.question (question, answer, status, createtime, updatetime) VALUES ("wenti", "daan", 0, now(), now())

    其中,now要加括号才行now()

    UPDATE dz_join SET close='1' ,pay='1', send='1' WHERE cid='1'

    SELECT a.questionid,a.question From similarquestion a INNER JOIN question b ON a.questionid=b.id AND b.status=0

    交集  

    数据库里出现很多 和空格

    一轮一轮做,用trim比较安全

    UPDATE question SET answer=trim(answer);
    UPDATE question SET answer=trim(" " from answer);
    UPDATE question SET answer=trim(answer);
    UPDATE question SET answer=trim(" " from answer);

    select id as 标准问题ID, question as 标准问题,"-" as 相似问题, answer as 答案 from question where question like "%进货单%"
    Union All
    select b.id as 标准问题ID, b.question as 标准问题, a.question as 相似问题, b.answer as 答案
    from similarquestion a inner join question b on a.questionid=b.id
    where a.question like "%进货单%"

    查两轮,把两轮的结果合并,使用union 关键字,注意,union是去除两个表里,重复的,而union all是不去除重复的

  • 相关阅读:
    前端学习(1)~html标签讲解(一)
    前端学习(0)~vscode工具使用
    微服务之部署
    分解单块系统
    c#之线程基础(一)
    如何在windows 7 上使用docker
    CodeForces 995B Suit and Tie(贪心,暴力)
    CodeForces 993B Open Communication(STL 模拟)
    CodeForces 993A Two Squares(数学 几何)
    CodeForces 996B World Cup(思维)
  • 原文地址:https://www.cnblogs.com/yjybupt/p/10045170.html
Copyright © 2011-2022 走看看