1.MySQL 中 You can't specify target table '表名' for update in FROM clause错误解决办法
原因是不能先select出同一表中的某些值,再update这个表(在同一语句中)。即不能依据某字段值做判断再来更新某字段的值。
问题解决:将SELECT出的结果再通过中间临时表包装一次,即SELECT一遍,这样就规避了错误。
2.字符串之子字符串操作
select distinct(substring_index(substring_index(agent, ')', 1), '(', -1)) agent,`userid`
from `z2_user_logs`
WHERE `userid` IS NOT NULL