2

I am working with a database and trying to get all the individual words that appear in 3 columns. I am SELECTing from columns title, description, and manufacturer, and using regexp_split_to_table to split into words on whitespace/punctuation/other relevant delimiters.

Right now I'm displaying 3 different columns, each with the results from title, description, and manufacturer respectively, but I want one column word where the results of all columns appear.

Here's what I have so far:

 SELECT regexp_split_to_table(trim(lower(title)), '\s+|[.()?<>!""@#$%&*;-_\/]+|[0-9]+|([0-9]+x{1}[0-9]+|[0-9]+|([0-9]+x{1}[0-9]+)')
        AS word1,
        regexp_split_to_table(trim(lower(description)), '\s+|[.()?<>!""@#$%&*;-_\/]+|[0-9]+|([0-9]+x{1}[0-9]+|[0-9]+|([0-9]+x{1}[0-9]+)')
        AS word2,
        regexp_split_to_table(trim(lower(manufacturer)), '\s+|[.()?<>!""@#$%&*;-_\/]+|[0-9]+|([0-9]+x{1}[0-9]+)\s+|[.()?<>!""@#$%&*\/]+|[0-9]+|([0-9]+x{1}[0-9]+)')
        AS word3
FROM amazon
LIMIT 500;
2
  • Wow, that's a lot of regex XD I recommend creating a temp field to combine the results into one. Commented Feb 25, 2017 at 20:40
  • Please add a small data sample, including required results, Commented Feb 25, 2017 at 20:41

1 Answer 1

1
select  regexp_split_to_table (title||' '||description||' '||manufacturer,'[^a-zA-Z]')

from    amazon
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.