Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
francisvandergr
Partner - Creator II
Partner - Creator II

Combine data from 2 databases

I have a question. I have 2 databases with 3 important tables. The tables in the different databases have the same fields. Example:

Database 1: Table GRBK Fields: Number,Year,Period,Amount

Database 2 Table GRBK Fields: Number,Year,Period,Amount

It is possible that both databases have the same data :

Database 1: Table GRBK 2000,2010,9,100

Database 2: Table GRBK 2000,2010,9,100

In Qlikview i need both records. Anybody knows how to combine both records ?

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Francis and welcome to the Forums,

Do something like the following:

LOAD *; SQL SELECT * FROM Database1; CONCATENATE LOAD *; SQL SELECT * FROM Database2;


Concatenate keyword is not needed when both tables have the same number of fields and fields are named alike. Anyway, I set it here should you have some differences between both tables.

Hope that helps

View solution in original post

6 Replies
Miguel_Angel_Baeyens

Hello Francis and welcome to the Forums,

Do something like the following:

LOAD *; SQL SELECT * FROM Database1; CONCATENATE LOAD *; SQL SELECT * FROM Database2;


Concatenate keyword is not needed when both tables have the same number of fields and fields are named alike. Anyway, I set it here should you have some differences between both tables.

Hope that helps

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

You could do something along these lines:


DATATABLE:
SQL SELECT Number,
Year,
Period,
Amount,
'Database1' AS Source
FROM Database1.GRBK;

CONCATENATE
SQL SELECT Number,
Year,
Period,
Amount,
'Database2' AS Source
FROM Database2.GRBK;


Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable

Try something like the following

CONNECTION STRING

Select

Orders_no,
Order_date,
Number,
Year,
Amount,
Period,
'DB1' as MyDatabase,
etc
From db1.scheme.orders_table;

CONCATENATE

CONNECTION STRING

Select

Orders_no,
Order_date,
Number,
Year,
Amount,
Period,
'DB2' as MyDatabase,
etc
From db2.scheme.orders_table;

francisvandergr
Partner - Creator II
Partner - Creator II
Author

Thanx to all. Jonathan i use your script. And of course it works. 🙂

francisvandergr
Partner - Creator II
Partner - Creator II
Author

Must i close this question on this forum?

Miguel_Angel_Baeyens

I'd recommed you to do that, so any other user looking for something similar will find the question as solved.