- HEX
[[email protected]][test]> select 16, HEX(16);
+----+---------+
| 16 | HEX(16) |
+----+---------+
| 16 | 10 |
+----+---------+
1 row in set (0.00 sec)
- CAST
[[email protected]][test]> create table test_col_sort( user char(10), type enum('aaa','zzz','bbb','yyy','fff'));
Query OK, 0 rows affected (0.34 sec)
[[email protected]][test]>
[[email protected]][test]>
[[email protected]][test]> select * from test_col_sort;
Empty set (0.00 sec)
[[email protected]][test]> select * from test_col_sort order by type;
Empty set (0.00 sec)
[[email protected]][test]> insert test_col_sort values ('user1', 'aaa');
Query OK, 1 row affected (0.53 sec)
[[email protected]][test]> insert test_col_sort values ('user2', 'zzz');
Query OK, 1 row affected (0.00 sec)
[[email protected]][test]> insert test_col_sort values ('user3', 'bbb');
Query OK, 1 row affected (0.01 sec)
[[email protected]][test]> insert test_col_sort values ('user4', 'yyy');
Query OK, 1 row affected (0.01 sec)
[[email protected]][test]> select * from test_col_sort order by type;
+-------+------+
| user | type |
+-------+------+
| user1 | aaa |
| user2 | zzz |
| user3 | bbb |
| user4 | yyy |
+-------+------+
4 rows in set (0.00 sec)
[[email protected]][test]> select* from test_col_sort order by cast(type as char) asc;
+-------+------+
| user | type |
+-------+------+
| user1 | aaa |
| user3 | bbb |
| user4 | yyy |
| user2 | zzz |
+-------+------+
4 rows in set (0.00 sec)
- CONCAT
[[email protected]][test]> select concat('I ', 'Love ', 'U');
+----------------------------+
| concat('I ', 'Love ', 'U') |
+----------------------------+
| I Love U |
+----------------------------+
1 row in set (0.00 sec)
标签:sort,函数,MySQL,sock,sec,mysql,test,root
From: https://www.cnblogs.com/gavin-zheng/p/17304728.html