Home >Database >Mysql Tutorial >MySQL实现类似Oracle中的decode()函数的功能

MySQL实现类似Oracle中的decode()函数的功能

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:56:473576browse

mysqlgt; select if(1=1,10,20);+---------------+| if(1=1,10,20) |+---------------+| 10 |+---------------+1 ro

mysql> select if(1=1,10,20);
+---------------+
| if(1=1,10,20) |
+---------------+
|            10 |
+---------------+
1 row in set (0.00 sec)

上面的代码就是mysql里面的,实现的功能和Oracle的decode()函数一样,例如:

 select decode(字段名,,表达式1,值1,表达式2,值2) from dual;

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn