Home >Database >Mysql Tutorial >mysql数据库字段判断语句_MySQL

mysql数据库字段判断语句_MySQL

WBOY
WBOYOriginal
2016-06-01 13:37:341227browse

bitsCN.com


mysql数据库字段判断语句

 

一、CASE field WHEN value THEN value WHEN ... THEN ... ELSE ... 

 

sample:

 

Sql代码  

select CASE usertype WHEN 1 '管理员' WHEN 2 THEN '策划' WHEN 3 THEN '测试员' ELSE '未定义' AS usertype FROM users  

 

二、IF( exp, value, value) 

Sql代码  

IF (1 = 1,'A','B')  

bitsCN.com
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