mysql常用操作

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常用操作)