Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

LOAD & SQL SELECT

Hi

When loading data from a SQL database i usually do it by the following 2 methods...using LOAD and typing each field name as what you want it to rename it to or just by using * and loading everything. How can i load all the fields in the table but automatically append the table name to the field name without having to type each 100 fields using the LOAD method?

I want to load it as *.tablename if that makes sense

LOAD
field1 as field1_table,

field2 as field2_table,

field3 as field3_table;

SQL SELECT *
FROM database.table;

or

SQL SELECT *

FROM database.table;


2 Replies
Not applicable
Author

Use the command "qualify".

for example:

qualify b;

load a,b from xxx.txt

the result of this script will give two fields:

xxx.b and a.

qualify * will Influence on all the fields in the script.

To change back use the command "unqualify".

Miguel_Angel_Baeyens

That's correct, but going a step further, your script may look like this

Qualify *; Unqualify Key; // I want to keep the key field so associate tables Table:LOAD Field1, // This will be loaded as Table.Field1 Key; // This will be loaded as keySQL SELECT Field1, KeyFROM database.table; Unqualify *; // Leave fieldnames as they are, without being prefixed


Note that doing this you will keep your data unlinked, so if you want to keep some relations you may have to do it manually.

Hope that helps