学习笔记: MySQL简单命令(增删改查)

75 阅读1分钟
-- 查找对应列
-- select id, author from blogs;
-- 条件查找
-- select * from blogs where title='标题1';
-- order by 以id desc 逆序 模糊查询%% 
-- select *from blogs where author like '%张%' order by id desc;
-- 设置安全更新模式
-- SET SQL_SAFE_UPDATES = 0;
-- 更新
-- update blogs set title='标题3' where content='内容2';

-- 删除
-- delete from blogs where title='标题3';blogs

-- 软删除--加上state 表示不可用,查询时只查找可用的数据,但原数据还在
-- select * from blogs where state='1';
-- update blogs set state='0' where author='张三'
-- select * from blogs where state='1';