Creating query expressions using regex | Community
Skip to main content
Level 3
September 26, 2017

Creating query expressions using regex

  • September 26, 2017
  • 1 reply
  • 3883 views

Hi,

If I want to query my database with a list of values, such as db Field that contains the values: 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, and 1010...etc. all the way up to 1100.

Instead of listing them individually, "1001, 1002, 1003, 1004, 1005, 1006, 1007...etc is there a way of using regex expressions to shorten these list of values (" 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010 all the way up to 1100") inside the query?

In other words, I don't want to list these values individually, since they are numerous, but rather, wish to shorten it through an expression. Can I use regex for that?

I am thinking "1001 - 1100" (1001 to 1100 in literal terms). Is this correct?

Thank you.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Jean-Serge_Biro
Level 10
September 26, 2017

Hello Jael,

Please might you explain why you intend to use regex for SQL queries instead standard SQL possibilities?

Usually regex is used in script languages (Javascript, JSSP for Adobe Campaign).

In SQL depending on field type you have these choices:

1. [numeric field] between operator in where clause, with query activity it doesn't exist so you must replace it by 2 clauses, one for superior or equal and the other one for inferior or equal; or if your query is not made through Query activity but by Javascript activity code, you can use between in direct SQL expressions or queryDef (or 2 clauses as for Query activity of course).

2. [varchar field] like operator with % placeholder sign.

If you must use regex for a reason or another, because Adobe Campaign Javascript support for regex is standard one, please refer to all public resources on regex on the web, and if needed support of regex in Javascript (mainly the same as in other languages).

Regards.
J-Serge

Level 3
October 3, 2017

Thank you again Jean-Serge!! Again, sorry for the late response as my Outlook filtered AC forum replies into the spam box for some reason. Will implement your suggestion! Very good to know that AC uses a JavaScript regex engine!

Thank you so much!

Jae