如何自动将MySQL列转换为小写 [英] How to automatically convert a MySQL column to lowercase

查看:323
本文介绍了如何自动将MySQL列转换为小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否存在可以添加到列中的属性,以便将其值转换为小写?而不是通过PHP对每个单个值执行此操作?

Is there a property that I can add to a column so that it converts its value to lowercase? Instead of doing it for every single value through PHP?

推荐答案

您可能可以通过视图该列的小写版本.视图的SQL可能看起来像

You could probably do it through a trigger that fires on insert or update. Myself, I'd rather just create a view that has a lower-case version of the column in question. The SQL for the view might look like

SELECT ID, LOWER(MY_COLUMN) AS MY_COLUMN_LOWERCASE
FROM MY_TABLE;

这篇关于如何自动将MySQL列转换为小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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