提交 5bd28275 编写于 作者: M Mars Liu

while

上级 a217dd69
{
"node_id": "mysql-923c7bbf96cf4630a5dfb36f15e62d24",
"keywords": [],
"keywords": ["repeat", "循环"],
"children": [],
"export": [],
"export": [
"repeat.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
......
{
"type": "code_options",
"author": "ccat",
"source": "repeat.md",
"notebook_enable": false,
"exercise_id": "12cc456d974d418dbd481b83a491da36"
}
\ No newline at end of file
# REPEAT
交易过程 trade 中有一个遍历交易项的循环,当累计的总交易额 `@total_price` 超过 20000, 这个循环就结束
```mysql
-- ...
trade: LOOP
-- ...
if @total_price > 20000 then
LEAVE trade;
else
ITERATE trade;
end if;
-- ...
end LOOP trace;
```
现在 Joe 想要用 `REPEATE` 简化这个 `LOOP` 循环,他应该怎么做?
## 答案
```mysql
trade: REPEATE
-- 省略交易过程
UNTIL @total_price > 20000
END REPATE trade;
```
## 选项
### A
```mysql
trade: REPEATE
UNTIL @total_price > 20000
-- 省略交易过程
END REPATE trade;
```
### B
```mysql
REPEATE @total_price > 20000
-- 省略交易过程
END REPATE;
```
### C
```mysql
trade: REPEATE
-- 省略交易过程
IF @total_price > 20000
END REPATE trade;
```
### D
```mysql
trade: REPEATE
IF @total_price > 20000
-- 省略交易过程
END REPATE trade;
```
{
"node_id": "mysql-8bbe6f55f32b4a4a8a6011c5748b36fa",
"keywords": ["while"],
"keywords": [
"while"
],
"children": [],
"export": [],
"export": [
"while.json"
],
"keywords_must": [],
"keywords_forbid": [],
"group": 0
......
{
"type": "code_options",
"author": "ccat",
"source": "while.md",
"notebook_enable": false,
"exercise_id": "91d3e7a524b54b6393acc7b80bd04621"
}
\ No newline at end of file
# WHILE
交易过程 trade 中有一个遍历交易项的循环,当累计的总交易额 `@total_price` 超过 20000, 这个循环就结束
```mysql
-- ...
trade: LOOP
-- ...
if @total_price > 20000 then
LEAVE trade;
else
ITERATE trade;
end if;
-- ...
end LOOP trace;
```
现在 Joe 想要用 `WHILE` 简化这个 `LOOP` 循环,他应该怎么做?
## 答案
```mysql
trade: WHILE @total_price > 20000
-- 省略交易过程
END WHILE trade;
```
## 选项
### A
```mysql
trade: DO
-- 省略交易过程
WHILE @total_price > 20000;
```
### B
```mysql
trade: WHILE @total_price > 20000
-- 省略交易过程
END WHILE trade;
```
### C
```mysql
trade: WHILE @total_price > 20000 DO
-- 省略交易过程
END WHILE trade;
```
### D
```mysql
trade: WHILE @total_price > 20000
-- 省略交易过程
END WHILE;
```
......@@ -2190,7 +2190,9 @@
{
"WHILE": {
"node_id": "mysql-8bbe6f55f32b4a4a8a6011c5748b36fa",
"keywords": [],
"keywords": [
"while"
],
"children": [],
"keywords_must": [],
"keywords_forbid": [],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册