mysql --查询
查询单个列 select [列名] from `[表名]`;
select id from `user`;
select id as user_id from `user`; 别名
查询多个列 select [列名1,列名2] from `[表名]`;
SELECT id,name from `user`;
查询所有列 select * from `[表名]`;
SELECT * from `user`;
排序 Order By [列名] desc (降序) asc(升序)
SELECT * from `user` ORDER BY age desc;
限制查询结果 limit [开始位置], [查询条数]
select * from `user` limit 0, 2;
条件查询 where [条件]
select * from `user` where age = 18;
多条件查询 where [条件1] and [条件2]
select * from `user` where age >= 20 and name = 'zxd';
select *from `user` WHERE age>20 or address = '福州'
-- 模糊查询 like [条件]
-- %z 以z结尾
-- z% 以z开头
-- %z% 包含z
select * from `user` where name like '%k%';