mysql语法知识总结

启动or关闭or重启服务
	service mysql start;	
	or	
	service mysql stop;
	or
	service mysql restart;
创建数据源
	create datebase xxx;
使用数据源
	use xxx;
DQL(数据查询语言)
  1. 查询语句的基本语法
	select * from tableName where 条件 group by 字段 order by 字段;
  • from关键字后面是表名,多个表明用逗号隔开
  • select后面是列名,多个列名用逗号隔开,*表示全部字段
  • 使用where子句对表中的数据筛选,结果为true的行会出现在结果集中
  1. 查询消除重复行
	select distinct 字段 from tableName;
  1. 比较运算符
  • 等于 =
	select * from tableName where id = 3;
	查询id等于3的用户
  • 小于 < (如果在sql脚本中要使用<)
	select * from tableName where id < 3;
	<script>
	select * from tableName where id &lt; 3
	</script>
	查询id小于3的用户
  • 大于 > (如果在sql脚本中要使用>)
	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;
	查询没被删除的用户
  1. 逻辑运算符
  • and 表示并且 XXX和XXX都要实现
	select * from tableName where id < 5 and id > 2;
	查询id大于2和id小于5的用户
  • or 表示或 XXX和XXX只要有一个符合就都查
	select * from tableName where id < 5 or name = 'xxx';
	查询id小于5或name等于xxx的用户
  1. 模糊查询
  • %表示任意多个任意字符
	select * from tableName where name like '李%'
	查询姓李的所有用户
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值