Home > Mobile >  Misspelled Data
Misspelled Data

Time:12-07

How to correct below misspelled data in column market:

market
SocialMediaAdvertising
SocialInvesting
FinancialExchanges
CloudMagement
VentureCapital

I don't know what syntax to write. But output should be as below:

market
Social Media Advertising
Social Investing
Financial Exchanges
Cloud Magement
Venture Capital

CodePudding user response:

Use can use the regexp_replace() function to insert each a space before each upper case letter. (See demo)

update markets  
   set market = ltrim(regexp_replace(market, '([A-Z])', ' \1', 'g'));

Caution: As presented this Updates every occurrence of an upper case letter inserting a space before it. The ltrim removes the space inserted at the beginning of the column. Any uppercase letter preceded by a space creates a double space. Make sure you validate result.

CodePudding user response:

You can run a series of SQL updates since there aren't many changes. For example

UPDATE your_table set market="Social Media Advertising" where market="SocialMediaAdvertising";
UPDATE your_table set market="Social Investing" where market="SocialInvesting";
UPDATE your_table set market="Financial Exchanges" where market="FinancialExchanges";
UPDATE your_table set market="Cloud Magement" where market="CloudMagement";
UPDATE your_table set market="Venture Capital" where market="VentureCapital";

Cautions: Be sure to replace your_table with the actual name of the table you want to update, for each SQL statement.

You might have a typo with "Magement", but I'm not sure

  • Related