0

I have a field, item_id, being passed from one transform step to another. I want to use that field multiple times in the next transform step for use in a UNION.

select x, y from table1 where item_id = ? UNION select w, z from table2 where item_id = ?

Since transforms do placeholder replacement in order by field, how do I make the item_id available to be used multiple times?

ed4becky
  • 1,488
  • 1
  • 17
  • 54

2 Answers2

0

One way is to make the two queries in a separate Input tables and direct the flow on the same step (next step can be any step):

enter image description here

An other way is to use parameters instead of variable:

select x, y from table1 where item_id = "${myParam}" UNION select w, z from table2 where item_id = "${myParam}".

An third way is the rewrite the query as

select * from (select x, y from table1 UNION select w, z from table2) where item_id = ?
AlainD
  • 6,187
  • 3
  • 17
  • 31
0

I used Select task to duplicate the values. Keeps it simple.

ed4becky
  • 1,488
  • 1
  • 17
  • 54