美文网首页
mysql常用操作

mysql常用操作

作者: 李孝伟 | 来源:发表于2018-04-19 10:31 被阅读3次

    1.where中字段包含条件

    find_in_set(a,b), b包含a;必须明确包含形式,a在b中是用英文字符‘,’隔开的,例如:find_in_set('xxx','xxx,mmm,nn');
    eg.
    update gms_agent_invoice_detail t set invoice_sn=(select a.invoice_sn from gms_agent_invoice a where find_in_set(t.invoice_id,a.invoice_code) ) where invoice_sn is null;
    

    2.字符串截取

    左侧截取三位:select left('sqlstudy.com', 3);-->: sql
    右侧截取三位:select right('sqlstudy.com', 3);-->: com
    从第4个字符开始截取2位:select substring('sqlstudy.com', 4, 2);-->: st
    

    相关文章

      网友评论

          本文标题:mysql常用操作

          本文链接:https://www.haomeiwen.com/subject/pbnikftx.html