Retrieving Soundex Codes from a Data Column in mysql

is it possible to make such a query in SQL: there is a column with names, let’s say FirstName, you need to get the soundex code for each name in the column and write these codes into the FirstNamesdx column?


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Are you trying something like this:

CREATE TABLE test_tbl(
             first_name VARCHAR(50),
             FirstNamesdx VARCHAR(50)

insert into test_tbl(first_name) values ('Earbuds'),
                                        ('Data Cable'),

Then you can use an update with the same table to get the needed values:

update test_tbl a
inner join 
( select first_name, SOUNDEX(first_name) as soundex_first_name 
  from test_tbl
) as b
on a.first_name=b.first_name
set a.FirstNamesdx=b.soundex_first_name;

You have an easy way:

update test_tbl
set FirstNamesdx= SOUNDEX(first_name);


Retrieving Soundex Codes from a Data Column in mysql

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x