Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How-To: Add Code to your Content


how to define this condition
if(tab1.dept_id='global' then tab2.dept_id
else tab1.dept_id)

in tab1 table, if the script is as below;

Qualify b_id;

l

oad a,d,c,b_id,dept_id;

SQL select * from tab1;


Qualify b_id;

load f,g,j,kk,

b_id,dept_id;
SQL Select * from tab1;

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

You should use a mapping load with an ApplyMap(), as follows:

Table2Map;

MAPPING LOAD b_id, dept_id; // b_id or the unique identifier between both tables

SQL select * from tab1;


Table1:

LOAD f, g, j, kk,

      b_id,

      If(dept_id = 'global', ApplyMap('Table2Map', b_id), dept_id) AS dept_id_new;
SQL Select * from tab1;

Hope that helps.

Miguel

View solution in original post

2 Replies
Miguel_Angel_Baeyens

Hi,

You should use a mapping load with an ApplyMap(), as follows:

Table2Map;

MAPPING LOAD b_id, dept_id; // b_id or the unique identifier between both tables

SQL select * from tab1;


Table1:

LOAD f, g, j, kk,

      b_id,

      If(dept_id = 'global', ApplyMap('Table2Map', b_id), dept_id) AS dept_id_new;
SQL Select * from tab1;

Hope that helps.

Miguel

Not applicable
Author

Thank you