Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Merging to SQL Tables (union way, vertically)

Hi.

my script looks like this:

Table_A:

select ... from ... where ... ;

Table_B:

select ... from ... where ... ;

I want to merge these tables into Table_C?

Table_C:

[What's the script for it?]

Thank YOU.

5 Replies
Not applicable

Re: Merging to SQL Tables (union way, vertically)

Hi Gil

Qlikview is very different from SQL in that the script is more step-wise.

The cleanest way to achieve a merge of table A and B would be to load table A, then merge B into it as the next step using the "concatenate" statement. This would be the equivalent of a SQL select * from A union select * from B.

TableA: Load * from TableA;

concatenate(TableA) Load * from TableB;

Both tableA and table B are in table A.

Qlikview will automatically pick up fieldnames that are the same and put the values in the same column. Where column B has different filednames, then the rows in (original) table A will be null for these new fields.

Erica

MVP
MVP

Re: Merging to SQL Tables (union way, vertically)



Table_C:

//Table_A:

sql select ... from ... where ... ;

concatenate (Table_C)

//Table_B:

sql select ... from ... where ... ;

MVP
MVP

Re: Merging to SQL Tables (union way, vertically)

Hi,

Try like this

Table_C:

select ... from ... where ... ;

Concatenate(Table_C)

select ... from ... where ... ;

Regards,

Jagan.

satyadev_j
Valued Contributor

Re: Merging to SQL Tables (union way, vertically)

Hi,

If the column names are identical in both the tables, you don't have to forcefully use "concatenate" to merge them together. QlikView will automatically merge them by writing below script and store them in table "Table_A"

Table_A:

select ... from ... where ... ;

Table_B:

select ... from ... where ... ;

If the names are not identical than using "concatenate" would be best option. See below,

Table_C:

select ... from ... where ... ;

Concatenate (Table_C)

select ... from ... where ... ;

vardhancse
Valued Contributor II

Re: Merging to SQL Tables (union way, vertically)

Table_A:

Load ... from ... where ... ;

left join(Table_A)

//Table_B:

Load ... from ... where ... ;

Both table_A and table_B will be in to one single table based on the one field join.

If you want to merge these tables into Table_C?

Table_C:

Load *,

resident Table_A;

Drop table Table_A;

it will create one seperate table and will drop table_A and table_B

Community Browser