MySQL数据处理常用SQL

 


 

SELECT * FROM timo_user WHERE CHAR_LENGTH(nickname) > 16;

UPDATE timo_user SET nickname = SUBSTRING(nickname, 1, 16) WHERE CHAR_LENGTH(nickname) > 16;

UPDATE timo_user SET openid = '' WHERE openid IS NULL;

UPDATE tb_activity a, (SELECT activity_id, COUNT(*) count FROM `tb_appointment` WHERE `status` = 1 GROUP BY activity_id) as b SET a.entry_num = b.count WHERE a.id = b.activity_id;