Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have 4 identical databases (tables, fields) with different names (society A, society B...).
And it can concatenate fields from the database but differ in an additional field added to the script:
example:
database A:
date
sale
seller
database B:
date
sale
seller
I wish a result:
date
sale
seller
database
thank you for your help.
twist
Hi,
That's very usual. You will have to both create the new field and use the CONCATENATE keyword in the second load and after is the fields are not the same to force concatenation:
Table:
LOAD *,
'Database1' AS Database;
SQL SELECT *
FROM Database1;
CONCATENATE (Table) LOAD *,
'Database2' AS Database;
SQL SELECT *
FROM Database2;
CONCATENATE (Table) LOAD *,
'Database3' AS Database;
SQL SELECT *
FROM Database3;
Hope that helps.
Miguel
Hi,
That's very usual. You will have to both create the new field and use the CONCATENATE keyword in the second load and after is the fields are not the same to force concatenation:
Table:
LOAD *,
'Database1' AS Database;
SQL SELECT *
FROM Database1;
CONCATENATE (Table) LOAD *,
'Database2' AS Database;
SQL SELECT *
FROM Database2;
CONCATENATE (Table) LOAD *,
'Database3' AS Database;
SQL SELECT *
FROM Database3;
Hope that helps.
Miguel
Thanks you for your help
twist
If the fields are and will always be exactly the same, it might be simpler to use a loop:
FOR EACH DB IN 'Society A','Society B','Society C','Society D'
Societies:
LOAD *, $(DB) as Database;
SQL SELECT Date, Seller FROM $(DB);
NEXT