xtrh.net
当前位置:首页 >> mysql iF语句 >>

mysql iF语句

如果是存储过程: insert into 这句后面应该添加 ; 如果是SQL语句,IF的用法完全不是这样的: 例子:select if(2>0,"正确","错误") from tab1; 楼主的目的是啥不清楚,可以参考如下的例子: insert into tab1 values( if(2>0,'aaaa','bbbb'));

mysql> DELIMITER //mysql> CREATE PROCEDURE TestIfElse -> ( -> p_val INT -> ) -> BEGIN -> IF (p_val = 1) THEN -> SELECT '1' AS A; -> ELSEIF (p_val = 2) THEN -> SELECT '2' AS A; -> ELSE -> SELECT 'other' AS A; -> END IF; -> END//...

MYSQL没有IF的语句,MYSQL使用的是MYSQL特色的SQL语句,它的WHERE和IF差不多,同样的条件判断 SELECT 字段 FROM 表名 where 条件

mysql> DELIMITER // mysql> CREATE PROCEDURE TestIfElse -> ( -> p_val INT -> ) -> BEGIN -> IF (p_val = 1) THEN -> SELECT '1' AS A; -> ELSEIF (p_val = 2) THEN -> SELECT '2' AS A; -> ELSE -> SELECT 'other' AS A; -> END IF; -> END/...

select *,if(sva=1,"男","女") as ssva from tableame where id =1 Quote 控制流程函数 CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result ...] [ELSE result] END CASE WHEN [condition] THEN result [WHEN [con...

if (@num1 < @time) AND (@num2 < @time) AND (@num3 < @time) then

有时候在修改某一个字段的值得时候我们需要根据当前字段的不同状态进行不同处理, 比如对于用户表,我们需要记录下来用户被访问的次数,但访问次数的初始值为 null。 如下: CREATE TABLE `test` ( `id` int(11) NULL DEFAULT NULL , `name` var...

mysql 触发器 if语句用法 @sqlz ='select asd from flkg'; EXECUTE(@sqlz); ---------- 首先,mysql下动态语句不是这样写的,另外,触发器里不能允许返回结果集的. 这里我是希望他能中断更新!

mysql的case 就是 类似switch的用法, SELECT id,case status WHEN '0' then '审核中' WHEN '1' then '通过' WHEN '3' then '禁用' end as "status" from tp_user if的用法: select *,if(sex=1,"男","女") as sex from tp_user

mysql 里面, 变量不需要加 @ 这个符号的呀 mysql> DELIMITER //mysql> CREATE PROCEDURE TestIfElse -> ( -> p_val INT -> ) -> BEGIN -> IF (p_val = 1) THEN -> SELECT '1' AS A; -> ELSEIF (p_val = 2) THEN -> SELECT '2' AS A; -> ELSE ->...

网站首页 | 网站地图
All rights reserved Powered by www.xtrh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com