We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

SQL Query with Regex

KimLamNg
9 - Comet

I'm trying to pull data from ODBC using SQL that matches a pattern in "cell_id" column. My query is SELECT * FROM table_name WHERE cell_id REGEX_Match ('NRANR\[\d\].Ttwanr14'). But this didn't work.

 

Can anyone help please?

4 REPLIES 4
ChrisTX
16 - Nebula
16 - Nebula

REGEX_Match is an Alteryx function.  You can't use it in a database query.

 

Sometimes you have to pull back more data that you need from the database, then filter with Alteryx tools / functions.

 

Chris

binuacs
21 - Polaris

@KimLamNg why don't you use the LIKE operator in your sql?

KimLamNg
9 - Comet

@binuacs Thank you for the suggestion. I wasn't aware of that operator. 

 

I was able to get it work for more than one pattern using this query: SELECT * FROM `data_table` WHERE `cell_id` LIKE 'NRANR[%].Ttwanr14' OR `cell_id` LIKE 'NRANR[%].Ttwanr136';

 

I had to use "%" instead of a regex.

 

apathetichell
20 - Arcturus

SQL is a universe of languages each which of which requires specific syntax. you can use regex in-db - but you'll need to review the specific type of SQL to get this to work (ie Snowflake/SQL Server/Postgres/Redshift/BigQuery etc...)

Labels
Top Solution Authors