Is there a MySQL command to convert a string to lowercase?

PhpMysql

Php Problem Overview


I have a MySQL database of keywords that are presently mixed-case. However, I want to convert them all to lowercase. Is there an easy command to do this, either using MySQL or MySQL and PHP?

Php Solutions


Solution 1 - Php

UPDATE table SET colname=LOWER(colname);

Solution 2 - Php

Yes, the function is LOWER() or LCASE() (they both do the same thing).

For example:

select LOWER(keyword) from my_table

Solution 3 - Php

SELECT LOWER(foo) AS foo FROM bar

Solution 4 - Php

You can use the functions LOWER() or LCASE().

These can be used both on columns or string literals. e.g.

SELECT LOWER(column_name) FROM table a;

or

SELECT column_name FROM table a where column = LOWER('STRING')

LCASE() can be substituted for LOWER() in both examples.

Solution 5 - Php

Did you try looking it up? Google, manual...

http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_lower

mysql> SELECT LOWER('QUADRATICALLY');
        -> 'quadratically'

Solution 6 - Php

Simply use:

UPDATE `tablename` SET `colnameone`=LOWER(`colnameone`);  

or

UPDATE `tablename` SET `colnameone`=LCASE(`colnameone`);

Both functions will work the same.

Solution 7 - Php

Interesting to note that the field name is renamed and if you reference it in a function, you will not get its value unless you give him an alias (that can be its own name)

Example: I use a function to dynamically get a field name value:

function ColBuilder ($field_name) {
…
While ($result = DB_fetch_array($PricesResult)) {
$result[$field_name]
}
…
}

my query being: SELECT LOWER(itemID), … etc..

needed to be changed to: SELECT LOWER(itemID) as itemID, … etc..

Solution 8 - Php

use LOWER function to convert data or string in lower case.

select LOWER(username) from users;

or

select * from users where LOWER(username) = 'vrishbh';

Solution 9 - Php

I believe in php you can use

strtolower() 

so you could make a php to read all the entries in the table then use that command to print them back as lower case

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionThomas OwensView Question on Stackoverflow
Solution 1 - PhpPaul DixonView Answer on Stackoverflow
Solution 2 - PhpJon GrantView Answer on Stackoverflow
Solution 3 - PhpGregView Answer on Stackoverflow
Solution 4 - PhpdmanxiiiView Answer on Stackoverflow
Solution 5 - PhpmyplacedkView Answer on Stackoverflow
Solution 6 - PhpVi8LView Answer on Stackoverflow
Solution 7 - PhpHD FrenchFeastView Answer on Stackoverflow
Solution 8 - PhpumaView Answer on Stackoverflow
Solution 9 - PhpRodent43View Answer on Stackoverflow