Search code examples
mysqlregextalend

Select Statement in Talend using REGEXP (MYSQL) to find spaces in a first name field


writing a select statement to view first names with spaces in them i.e. JO ANN or TERRY LYNN,

my statement format would look like:

SELECT FirstName FROM `DB`.`TABLE` where FirstName REGEXP ' ' 

I know the names exist because I can see them in the preview i just need to write a select statement to only view the names with spaces


Solution

  • It's better to use POSIX class which matches all the space characters because your's won't match the names which has tabs.

    SELECT FirstName FROM `DB`.`TABLE` where FirstName REGEXP '[[:space:]]' 
    

    This would match the names only if there exists a space between two alphabets.

    SELECT FirstName FROM `DB`.`TABLE` where FirstName REGEXP '[[:alpha:]][[:blank:]]+[[:alpha:]]'