Mysql增删改查


create

1
2
INSERT INTO tasks(subject,start_date,end_date,description)
VALUES('Learn MySQL INSERT','2017-07-21','2017-07-22','Start learning..');

read 左右链接

1
2
3
4
5
6
7
SELECT
    plugin_of_user.id, plugin_of_user.user_plugin_name,
    plugin_info.name, plugin_info.avatar, plugin_info.link, plugin_info.type
FROM plugin_of_user
RIGHT JOIN plugin_info
ON plugin_of_user.plugin_id=plugin_info.id
WHERE plugin_of_user.user_id = ?

update

1
2
3
4
5
6
7
UPDATE [LOW_PRIORITY] [IGNORE] table_name 
SET 
    column_name1 = expr1,
    column_name2 = expr2,
    ...
WHERE
    condition;

无则添加,有则修改

1
2
3
4
5
6
insert into student
  (number, name) 
values
  (45,‘张三’)
ON DUPLICATE KEY UPDATE 
number = 46, name = ‘李四’;

delete

1
2
DELETE FROM table_name
WHERE condition;
updatedupdated2020-10-122020-10-12