1、substr的索引是从1开始的 而非0
2、当我们想复制某些表的某些字段到另一个表的时候,应该区分是新增还是update
2.1 insert
insert into user_info_related(uid,wx_m_openid,wx_unionid)
select id,wx_s_openid,wx_unionid
from user_info;
2.2、用update复制可能出错
insert user_info_related ,user_info
SET user_info_related.wx_m_openid = user_info.wx_s_openid
where条件加上主键就好了 where … and A.id > 0
MySql运行在safe-updates模式下,导致非主键条件下无法执行update或者delete命令
3、当我们使用join,但是有两个相同的字段(但是其值不一定相同),比如A.sex,B.sex,通过name=name连接。此时筛选A.sex=男,如果选择的列为全部的话,那么最后的结果只有一个sex(B的),你会发下where条件失效 sex可能有女。所以在写where的时候,还得加上B.sex=女