启动or关闭or重启服务
service mysql start ;
or
service mysql stop;
or
service mysql restart;
创建数据源
create datebase xxx;
使用数据源
use xxx;
DQL(数据查询语言)
查询语句的基本语法
select * from tableName where 条件 group by 字段 order by 字段;
from关键字后面是表名,多个表明用逗号隔开 select后面是列名,多个列名用逗号隔开,*表示全部字段 使用where子句对表中的数据筛选,结果为true的行会出现在结果集中
查询消除重复行
select distinct 字段 from tableName;
比较运算符
select * from tableName where id = 3 ;
查询id等于3 的用户
select * from tableName where id < 3 ;
< script>
select * from tableName where id & lt; 3
< / script>
查询id小于3 的用户
select * from tableName where id > 3 ;
or
< script>
select * from tableName where id & gt; 3
< / script>
查询id大于3 的用户
select * from tableName id != 3 ;
查询id不等于3 的用户
select * from tableName where isdelete = 0 ;
查询没被删除的用户
逻辑运算符
select * from tableName where id < 5 and id > 2 ;
查询id大于2 和id小于5 的用户
select * from tableName where id < 5 or name = 'xxx' ;
查询id小于5 或name等于xxx的用户
模糊查询
select * from tableName where name like '李%'
查询姓李的所有用户