CMS Development

CMcNamee
Contributor | Elite Partner
Contributor | Elite Partner

Hubdb complex queries using AND and OR logic combined

SOLVE

Let's say I have a table with columns: category, material, state, building type.  And I want to use complex query logic by combining AND and OR, for example:

 

all rows where category=residential AND (material = clay OR material = asphalt) AND (state = IL) AND (building type = maintenence OR building type = storm)

 

How would I go about doing this with Hubl?  Is this possible?  I have looked through the hubdb documentation and also the api documentation and I didn't find anything about complex logic.

0 Upvotes
1 Accepted solution
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Hubdb complex queries using AND and OR logic combined

SOLVE

@CMcNamee If you're using multiselect columns for the ones you want to do an OR query on you can use the __in expression and a comma to separate the options you want to check against.

 

 

{% set rows = hubdb_table_rows(XXXXXX, '&category__eq=residential&state=IL&material__in=clay,asphalt&building_type__in=maintenence,storm') %}

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.

View solution in original post

2 Replies 2
alyssamwilie
Solution
Recognized Expert | Elite Partner
Recognized Expert | Elite Partner

Hubdb complex queries using AND and OR logic combined

SOLVE

@CMcNamee If you're using multiselect columns for the ones you want to do an OR query on you can use the __in expression and a comma to separate the options you want to check against.

 

 

{% set rows = hubdb_table_rows(XXXXXX, '&category__eq=residential&state=IL&material__in=clay,asphalt&building_type__in=maintenence,storm') %}

 

If this answer solved your question, please mark it as the solution.

Alyssa Wilie Profile Image

Alyssa Wilie

Web Developerat Lynton

Learn HubL | Get Marketing Insights

HubSpot Elite Solutions Partner
Lynton's HubSpot theme Rubric now available. Click to download.
dennisedson
HubSpot Product Team
HubSpot Product Team

Hubdb complex queries using AND and OR logic combined

SOLVE

Hey @CMcNamee 

Welcome to the Community!

This is right up the alley of @alyssamwilie and @Gonzalo !

Maybe they can help out!