有没有简单的方法可以将MySQL数据转换为Title Case? [英] Is there a simple way to convert MySQL data into Title Case?

查看:70
本文介绍了有没有简单的方法可以将MySQL数据转换为Title Case?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MySQL表,其中一列中的所有数据都以大写形式输入,但我需要转换为Title Case,并识别类似于

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:

  1. 将表导出为.sql格式的文本文件.
  2. Textmate (我已经很方便了)中打开文件.
  3. 选择包含大写数据的行.
  4. 从文本"菜单中选择转换",然后选择至标题栏".
  5. 查找并替换以下每个实例:

  1. Export the table as a text file in .sql format.
  2. Open the file in Textmate (which I already had handy).
  3. Select the rows with UPPERCASE data.
  4. Choose "Convert" from the "Text" menu, and select "to Titlecase".
  5. Find and replace each instance of:

INSERT INTO `Table` (`Col1`, `Col2`, `Etc`, ...) VALUES

带有正确的小写字母值.

with the correct lowercase 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆