Search code examples
mysqlsqlselectuppercase

How To Apply REPLACE and UPPER Simultaneously On One Column In SQL


I would like to remove any white spaces in my id column and capitalize it simultaneously. The below code gives me a separate column where one is the removed white spaces and the other is the capitalized. Is it possible to apply both REPLACE and UPPER so that the output is one column instead of two ?

SELECT REPLACE(id, ' ', ''), UPPER(id) FROM db

Solution

  • You can call one on the result of the other:

    SELECT UPPER(REPLACE(id, ' ', '')) FROM db