Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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