0

I am new to jinja2. I have a table (table 1) which have one row only, and I want to use a column value of this table in where clause of another query. e.g.

table1:

enter image description here

Now I want to use col2 value to another query which should look like:

SELECT col100, col101, col102
FROM table 2
WHERE col100 = 'ABC'

Can I make statement inside where clause (col100 = 'ABC') as a variable in jinja2 and take this where clause statement from table 1 (this table's data changes)

I tried few things mentioned in Store result of a query in a variable ( jinja), also something like:

{% set clause = 'select col2 from table1' %}
    
SELECT DISTINCT col100, col101, col102
FROM table2
WHERE '{{clause}}'

but nothing seems to work. Can someone please help me on this.

Thanks in advance!

Pardeep Naik
  • 99
  • 1
  • 12

0 Answers0