between.md 925 字节
Newer Older
M
having  
Mars Liu 已提交
1 2 3
# Between

Joe 要查询 goods 表
fix bug  
张志晨 已提交
4
```sql
M
having  
Mars Liu 已提交
5 6 7 8 9 10 11 12 13 14 15 16
create table goods(
    id int primary key auto_increment,
    category_id int,
    category varchar(64),
    name varchar(256),
    price decimal(12, 4),
    stock int,
    upper_time timestamp
)
```
中价格在 1000 到 2000 之间(包含1000和2000)的数据,以下查询中错误的是:

M
Mars Liu 已提交
17 18
<hr/>

F
feilong 已提交
19
点击进入[MySQL实战练习环境](https://mydev.csdn.net/product/pod/new?image=cimg-centos7-skilltreemysql&connect=auto&create=auto&utm_source=skill){target="_blank"}。
F
feilong 已提交
20

F
feilong 已提交
21 22
* `show databases;` 列出所有数据库
* `show tables;` 列出所有表
M
Mars Liu 已提交
23

M
having  
Mars Liu 已提交
24 25
## 答案

fix bug  
张志晨 已提交
26
```sql
M
having  
Mars Liu 已提交
27 28 29 30 31 32 33 34
SELECT * FROM goods HAVING price BETWEEN 1000 AND 2000;
```


## 选项

### A

fix bug  
张志晨 已提交
35
```sql
M
having  
Mars Liu 已提交
36 37 38 39 40
SELECT * FROM goods WHERE price BETWEEN 1000 AND 2000;
```

### B

fix bug  
张志晨 已提交
41
```sql
M
having  
Mars Liu 已提交
42 43 44 45 46
SELECT * FROM goods WHERE price >= 1000 AND price <= 2000;
```

### C

fix bug  
张志晨 已提交
47
```sql
M
having  
Mars Liu 已提交
48 49 50
SELECT * FROM goods WHERE not (price < 1000 or price > 2000);
```