Skip to content
Advertisement

Extract substring from column based on values from another table in SQL

In SQL (let’s assume ANSI standard SQL), is it possible to extract a substring from one column, based on another table, and put this substring into another column?

Example, from the following tables:

The idea is to extract the location from the summary column and output the following:

Advertisement

Answer

You can do pattern matching:

As commented by jarlh ANSI sql has operator || for string concatenation, so, depending on your database:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement