user2021539
user2021539

Reputation: 967

Update a field in SQL

I have several tables that have a common field (column) called LastName in a MySQL database. Several of the rows in these tables are in mixed case so they don't get selected properly when doing a SELECT.

How can I convert those columns to all UPPER CASE? I can easily handle any new entries to convert them to upper case, but the existing records I'm not so sure about.

Upvotes: 0

Views: 52

Answers (3)

Evans Murithi
Evans Murithi

Reputation: 3257

this would work:

UPDATE table_name SET `column_name` = UPPER( `column_name` )

Upvotes: 1

Sachu
Sachu

Reputation: 7766

You can use the string function UPPER() to make the column value to upper

update Your_table set LastName=UPPER(LastName)

Upvotes: 1

PaulF
PaulF

Reputation: 6773

would do the job

update table set LastName=UPPER(LastName);

NOTE - if you are running from MySQL workbench you may have to disable safety mode or add a where clause (eg WHERE id>0) otherwise it wont run.

Upvotes: 2

Related Questions