Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6240481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:34:42+00:00 2026-05-24T11:34:42+00:00

In MySQL I need to remove all single characters from a string: A Quick

  • 0

In MySQL I need to remove all single characters from a string:

"A Quick Brown B C D Fox" -> "Quick Brown Fox"

Any tips ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:34:43+00:00Added an answer on May 24, 2026 at 11:34 am

    You want [[:<:]] and [[:>:]] to search for word boundries in MySQL. (It would be \b in other regular expressions, PERL, grep, etc.)

    So…

    '[[:<:]][a-zA-Z0-9][[:>:]]'

    Would find any single character.

    OK TRY THIS…

    This is based upon the function above, but hardcoded to look for single characters. I don’t claim this to be much more than a hack. But if you need to get the job done, and you cant install the external libraries for whatever reason, it won’t slow you down on strings that do NOT have any single characters to replace:

    delimiter //
    DROP FUNCTION IF EXISTS `REMOVE_SINGLE_CHARS`//
    CREATE FUNCTION `REMOVE_SINGLE_CHARS`(original varchar(1000)) RETURNS varchar(1000) CHARSET utf8 DETERMINISTIC
    BEGIN
    
    DECLARE rxChars VARCHAR(20);
    DECLARE temp VARCHAR(1000);
    DECLARE ch1 CHAR(1);
    DECLARE ch2 CHAR(1);
    DECLARE ch3 CHAR(1);
    DECLARE i INT;
    
    SET rxChars = '[a-zA-Z0-9]';
    SET i = 1;
    SET temp = "";
    
    IF original REGEXP CONCAT('[[:<:]]',rxChars,'[[:>:]]') THEN
      loop_label: LOOP
        set ch1 = SUBSTRING(original,i,1);
        if CHAR_LENGTH(original) > i THEN 
          set ch2 = SUBSTRING(original,i+1,1);
        END IF;
        if CHAR_LENGTH(original) > i+1 THEN 
          set ch3 = SUBSTRING(original,i+2,1);
        END IF;
        if(i = 1) THEN
            IF (ch1 NOT regexp rxChars OR ch2 regexp rxChars) THEN
              set temp = CONCAT(temp, ch1);
            END IF;
        END IF;
    
        IF(ch2 = ' ') THEN
          # Theoretically this is redundant, but for some reason the
          # CONCAT(temp, ch2) below is not working when ch2 = ' '   YMMV
          set temp = CONCAT(temp, ' ');
        ELSE 
          IF(ch2 NOT regexp rxChars OR ch1 regexp rxChars OR (i+1<CHAR_LENGTH(original) AND ch3 regexp rxChars)) THEN
            set temp = CONCAT(temp, ch2);
          END IF;
        END IF;
    
        IF i+2>CHAR_LENGTH(original) THEN
          LEAVE loop_label;
        END IF;
        SET i=i+1;
      END LOOP;
    ELSE
      SET temp = original;
    END IF;
    RETURN temp;
    
    END//
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've found this at connection strings.com http://connectionstrings.com/mysql Do I need to download connector-net from
I need to modify the following MySQL statement to include information from a third
I need to access a mysql database from c# code but I would prefer
I'd need a MySQL query that moves a node and all its children within
I need help with displaying images from a MySQL database. What I have is
Mysql: i need to get the offset of a item in a query. I
I am newbee with PHP and MySQL and need help... I have two tables
Why you may ask? Because i have built the app on mysql and need
I need a MySQL query (or function) to calculate the geographic midpoint of an
I need to install mysql on the system. As usual I typed in gem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.