建表及插入数据语句:
mysql> create table salary(userid int,salary decimal(9,2));
Query OK, 0 rows affected (0.11 sec)
mysql> insert into salary values(1,1000),(2,2000),(3,3000),(4,4000),(5,5000),(1,
null);
Query OK, 6 rows affected (0.13 sec)
Records: 6 Duplicates: 0 Warnings: 0
1.if(value,t,f)函数:这里认为高于2000就是'high',其他都是low
mysql> select if(salary>2000,'high','low') from salary;
+------------------------------+
| if(salary>2000,'high','low') |
+--------------......
阅读全文