<pre name="code" class="sql">mysql> select * from ClientLoginDevice;
+--------------+
| machineModel |
+--------------+
| Android01 |
| Android02 |
| Android03 |
| Androidpc |
| ios01 |
| ios02 |
| ios03 |
| ios04 |
| iospc |
| pc01 |
| pc02 |
+--------------+
11 rows in set (0.00 sec)
mysql> SELECT machineModel,
-> CASE
-> WHEN machineModel LIKE '%Android%' THEN 'Android'
-> WHEN machineModel LIKE '%ios%' THEN 'ios'
-> WHEN machineModel LIKE '%wechat%' THEN 'wechat'
-> ELSE 'pc'
-> END AS machineModel
-> FROM ClientLoginDevice
-> GROUP BY machineModel;
+--------------+--------------+
| machineModel | machineModel |
+--------------+--------------+
| Android01 | Android |
| Android02 | Android |
| Android03 | Android |
| Androidpc | Android |
| ios01 | ios |
| ios02 | ios |
| ios03 | ios |
| ios04 | ios |
| iospc | ios |
| pc01 | pc |
| pc02 | pc |
+--------------+--------------+
11 rows in set, 1 warning (0.00 sec)
可以看到Androidpc 同时匹配Android和pc,但是统计时都算入到Android 类型
iospc 也是同样的道理