帮助中心
- 平台介绍
- 接入指引
- 版本信息
- 使用流程
- 功能手册
- 操作视频
- 技术文档
- 基础知识
- 客户端SDK
- 服务端SDK
- 数据导入
- API功能
- SQL手册
- DML
- SQL函数
- 日期函数
- convert_tz
- curdate,current_date
- current_timestamp
- curtime,current_time
- date_add
- date_format
- date_sub
- datediff
- day
- dayname
- dayofmonth
- dayofweek
- dayofyear
- from_days
- from_unixtime
- hour
- makedate
- minute
- month
- monthname
- now
- second
- str_to_date
- time_round
- timediff
- timestampadd
- timestampdiff
- to_date
- to_days
- unix_timestamp
- utc_timestamp
- week
- weekday
- weekofyear
- year
- yearweek
- localtime,localtimestamp
- quarter
- last_day
- extract
- date_trunc
- minutes_add
- minutes_diff
- minutes_sub
- seconds_add
- seconds_diff
- seconds_sub
- hours_add
- hours_diff
- hours_sub
- days_add
- days_diff
- days_sub
- weeks_add
- weeks_diff
- weeks_sub
- months_add
- months_diff
- months_sub
- years_add
- years_diff
- years_sub
- 字符串函数
- append_trailing_char_if_absent
- to_base64
- from_base64
- ascii
- length
- bit_length
- char_length
- lpad
- rpad
- lower
- lcase
- upper
- ucase
- initcap
- repeat
- reverse
- char
- concat
- concat_ws
- substr
- substring
- sub_replace
- ends_with
- starts_with
- trim
- ltrim
- rtrim
- null_or_empty
- not_null_or_empty
- hex
- unhex
- elt
- instr
- locate
- find_in_set
- replace
- left
- right
- strleft
- strright
- split_part
- split_by_string
- substring_index
- money_format
- parse_url
- convert_to
- extract_url_parameter
- uuid
- space
- sleep
- 日期函数
- 数据类型
- 数据管理
- 常见问题
- 合规说明
- 资源下载
- AB测试
convert_to
convert_to
description
Syntax
VARCHAR convert_to(VARCHAR column, VARCHAR character)
在order by子句中使用,例如order by convert(column using gbk), 现在仅支持character转为’gbk’. 因为当order by column中包含中文时,其排列不是按照汉语拼音的顺序. 将column的字符编码转为gbk后,可实现按拼音的排列的效果.
exmaple
mysql> select * from class_test order by class_name;
+----------+------------+-------------+
| class_id | class_name | student_ids |
+----------+------------+-------------+
| 6 | asd | [6] |
| 7 | qwe | [7] |
| 8 | z | [8] |
| 2 | 哈 | [2] |
| 3 | 哦 | [3] |
| 1 | 啊 | [1] |
| 4 | 张 | [4] |
| 5 | 我 | [5] |
+----------+------------+-------------+
mysql> select * from class_test order by convert(class_name using gbk);
+----------+------------+-------------+
| class_id | class_name | student_ids |
+----------+------------+-------------+
| 6 | asd | [6] |
| 7 | qwe | [7] |
| 8 | z | [8] |
| 1 | 啊 | [1] |
| 2 | 哈 | [2] |
| 3 | 哦 | [3] |
| 5 | 我 | [5] |
| 4 | 张 | [4] |
+----------+------------+-------------+
作者:超级管理员 创建时间:2023-06-15 10:08
最后编辑:超级管理员 更新时间:2024-09-05 21:06
最后编辑:超级管理员 更新时间:2024-09-05 21:06