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?
Answers:
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'), ('Phone'), ('Charger'), ('Data Cable'), ('Speakers');
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);
Demo: https://www.db-fiddle.com/f/pB6b5xrgPKCivFWcpQHsyE/8
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0