How to automatically convert a MySQL column to lowercase

前端 未结 2 1828
滥情空心
滥情空心 2021-01-23 20:41

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?

2条回答
  •  甜味超标
    2021-01-23 21:06

    Yes, but don't do it.

    If you want exclusively lowercase characters in a column, convert them when you insert (or update) them.

    If you need a column to be case insensitive in comparisons, use a case insensitive collation (which are used by default in e.g. utf8 columns)

提交回复
热议问题