首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql中if esle 有关问题

2012-05-21 
mysql中if esle 问题在sqlserver 中的语句:if (not exists (select null from tb where ExpLevel0))selec

mysql中if esle 问题
在sqlserver 中的语句:
if (not exists (select null from tb where ExpLevel=0)) 
select 0 as Experience
else 
select Experience from tb where ExpLevel=0
在mysql中要怎么写呢??
求帮助!

[解决办法]
DELIMITER $$
CREATE PROCEDURE ff()
BEGIN
IF (NOT EXISTS (SELECT NULL FROM tb WHERE ExpLevel=0)) THEN
SELECT 0 AS Experience;
ELSE
SELECT Experience FROM tb WHERE ExpLevel=0;
END IF;
END$$
DELIMITER ;
[解决办法]
不能,MYSQL不支持匿名块
[解决办法]
MySQL流程控制实例,详细介绍:

http://blog.csdn.net/business122/article/details/7565653

热点排行