Alteryx Designer Desktop Discussions

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

SQL Query with Regex

KimLamNg
8 - Asteroid

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
15 - Aurora

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
20 - Arcturus

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

KimLamNg
8 - Asteroid

@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
18 - Pollux

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