Is there a simple way to convert MySQL data into Title Case?(有没有一种简单的方法可以将 MySQL 数据转换为 Title Case?)
问题描述
我有一个 MySQL 表,其中一列中的所有数据都以大写形式输入,但我需要转换为标题大小写,并识别类似于 大胆的火球标题案例脚本.
I have a MySQL table where all the data in one column was entered in UPPERCASE, but I need to convert in to Title Case, with recognition of "small words" akin to the Daring Fireball Title Case script.
我发现了这个优秀的解决方案 用于将字符串转换为小写,但 Title Case 函数似乎已被排除在我的 MySQL 版本之外.有没有一种优雅的方法来做到这一点?
I found this excellent solution for transforming strings to lowercase, but the Title Case function seems to have been left out of my version of MySQL. Is there an elegant way to do this?
推荐答案
哇!我根本不擅长 SQL;这是对我有用的方法:
Woo! I'm not handy with SQL at all; Here's the method that worked for me:
- 将表导出为 .sql 格式的文本文件.
- 在 Textmate(我已经手头上)中打开文件.
- 选择包含大写数据的行.
- 从文本"菜单中选择转换",然后选择到标题框".
查找并替换以下各项的每个实例:
- Export the table as a text file in .sql format.
- Open the file in Textmate (which I already had handy).
- Select the rows with UPPERCASE data.
- Choose "Convert" from the "Text" menu, and select "to Titlecase".
Find and replace each instance of:
INSERT INTO `Table` (`Col1`, `Col2`, `Etc`, ...) VALUES
使用正确的小写值.
我之前没有尝试使用 Textmate 的原因是我无法弄清楚如何在不破坏其他数据的情况下将单个列转换为 Title Case,但这种方法似乎有效.感谢您的指导和支持!
The reason I didn't try using Textmate before was that I couldn't figure out how to convert a single column to Title Case without ruining the other data, but this method seems to work. Thanks for your guidance and support!
这篇关于有没有一种简单的方法可以将 MySQL 数据转换为 Title Case?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:有没有一种简单的方法可以将 MySQL 数据转换为 Title Case?
基础教程推荐
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- 无法解决整理冲突 2021-01-01
