MySQL 命令 和 where 子句中使用的运算符
君哥
阅读:2295
7年前
评论:0
| 说明 | MySQL 命令 |
|---|---|
| 创建数据库 | create database 数据库名称 |
| 切换数据库 | use 数据库名称 |
| 显示数据库 | show databases |
| 删除数据库 | drop database 数据库名称 |
| 创建数据表 | create table 表名 { 数据 } |
| 显示数据表 | show tables |
| 删除数据表 | drop table 表名 |
| 查询数据 |
select * from 表名 select 列名 from 表名 |
| 增添数据 | insert into 表名 (列名1, 列名2, ...) values (`值1`, `值2`, ...) |
| 修改数据 | update 表名 set 列名1=新值1, 列名2=新值2, ... where 列名=值1 |
| 删除数据 | delete from 表名 where 列名=值 |
| where 子句 查询条件 |
(1) select 列名 from 表名 where 列名 运算符 值 (2) update 表名 set 列名=新值 where 列名 运算符 值 (3) delete from 表名 where 列名 运算符 值 |
| order by 子句 数据排序 |
(1) select * from 表名 order by 列名 asc (升序排序) (2) select * from 表名 order by 列名 desc (降序排序) (3) select * from 表名 order by 列名1 desc, 列名2 asc (多重排序) |
| count(*) 函数 统计数据条数 | select count(*) from 表名 |
| as 为列设置别名 | select 列名1 as 别名1, 列名2 as 别名2 from 表名 |
| 操作符 | 描述 |
|---|---|
| = | 等于 |
| <> 与 != | 不等于 |
| > | 大于 |
| < | 小于 |
| >= | 大于等于 |
| <= | 小于等于 |
| between ... and ... | 在某个范围内 |
| like | 搜索某种模式 |
| like `%需要搜索的内容%` | 搜索包含 '需要搜索的内容' 的数据 |
| and | 并且 (相当于js中的 && 运算符) |
| or | 或者 (相当于js中的 || 运算符) |
发表评论
