Full table synchronization operation: Use the field t1.a of one table to update the field t2.b of another table in the table, replace all the fields in the entire table t1.a, and associate the condition t1.c=t2.c
UPDATE
user_record t1,
`user` t2
SET
t1.a = t2.b
WHERE t1.c = t2.c;
Summary operation: all the contents of a table are deduplicated according to user_id and type, the latest record is selected, and they are summarized into another table
INSERT INTO `user_choose` (user_id, TYPE, username, phone)
(SELECT
user_id,
TYPE,
username,
phone
FROM
user_choose_log
WHERE id IN
(SELECT
MAX(id)
FROM
user_record
WHERE user_id > 0
GROUP BY user_id,
TYPE)
);
In the same table, change the order of the table fields: put the username and phone fields after the id field
ALTER TABLE `user`
MODIFY `username` VARCHAR (63) DEFAULT NULL AFTER `id`,
MODIFY `phone` VARCHAR (63) DEFAULT NULL AFTER `id`;