mysql复合语句问题_mysql复合语句

更新时间:2023-06-22 12:53:53 阅读: 评论:0

mysql复合语句问题_mysql复合语句1 索引
create index on
drop index on
manifesto
2 视图 view 虚表 存放某⼀个查询的结果
create view 视图名称 as lect 语句
对视图进⾏操作
1查询 lect * from 视图名称
更新操作时候需要判断以下条件
1 不能有聚集函数 不能有 group by
create view v1 as lect max(age) from emp
2 不能有⼦查询
完了的英文3 不能有计算结果列
2 执⾏ 更新操作
inrt
delete
update
3 drop view 视图;
-----------------------------------------
复合语句 (必须放在存储过程或者函数⾥⾯)
fancl卸妆油怎么样
存储过程 实现特定功能的⼀组SQL语句 根据需要可以传参数
语法怎样查会计考试成绩
BEGIN
复合语句
END;
#1 声明变量
# 声明变量 declare 变量名称 变量类型
# 变量声明必学写在 其他复合语句之前
declare i int; #定义⼀个int的变量i
declare name varchar(20);#定义⼀个varchar的变量name
#声明变量的时候指定默认值
declare address varchar(50) default '⽆锡';
#2 赋值
t i = 100;
t name = '蔡亦超';
#3 分⽀语句
#1) if-el-then
if i > 90 then
# 结果设置为 优
t result = '优';
end if;#注意结束
if i > 90 && i <100 then拉瓦尔
# 结果设置为 优
t result = '优';
el if i > 80 then
t result = '良';steals
el
t result = '及格';
end if;
end if;#注意结束
# 2) ca when
lect
address as '⽬的地',
ca address
when '重庆' then '⽕锅'
when '海⼝' then '⽔果'
ambrosia
when '贵阳' then '丝娃娃'
end
as '特产'
from emp;
BEGIN
declare emp_id int; # 临时变量存放id
declare emp_salary int;# 临时变量存放salary
cc是什么意思declare done int default fal;# done表⽰还有没有数据BEGIN
循环
#1)while 循环
declare i int;
declare sum int;
declare temp_salary int;
# 获取当前⼯资 存⼊ temp_salary
beanstalklect salary into temp_salary from emp where id=1001;
while temp_salary <1000000 do
t temp_salary = temp_salary +5000;
end while;
# 更新最新的⼯资
update emp t salary = temp_salary where id=1001;
#2)loop 循环 temp_salary=1000000
loop1 : loop # loop1 是循环的标签
t temp_salary = temp_salary -2000;# 循环的内容
if temp_salary > 500000 then
iterate loop1; # temp_salary > 500000 继续循环 让代码再回到loop1位置end if;
leave loop1; # 结束循环
end loop;
update emp t salary = temp_salary where id=1001;
#3)repeat
t i=1;
t sum=0;
repeat # 重复执⾏以下代码
t i = i+1;
t sum = sum +i;tale
until i>10 # 直到 i>10为⽌
end repeat;
END
BEGIN
#异常处理
# 1 sqlstate 标准SQL的错误代码 5

本文发布于:2023-06-22 12:53:53,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1013545.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:变量   循环   语句   不能
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图