I would like to find a way of writing a SELECT statement which includes using the column name as a search criteria in a data_glossary table.
Example SQL statement
SELECT field1, field2, field3
FROM table1
I want to include field_definition
from a table called tbl_data_glossary
using WHERE data_reference = 'field1'
whenever I run a script. So I should get two data sets, the first one has the data, the second has what the data set values mean.
I hope that makes sense, I want to implement this in a way where a BI tool could not only pull values but include the information required to provide help for business users.
I have tagged this as SQL and Javascript but maybe you have a better way of approaching this.
I wonder if I need to setup my select statement using an array of variables somehow and then also use the same array in a WHERE data_reference IN [array]
type statement.
So, if one of the fields in my SELECT statement is reference_definition_name
I want a sub query or separate query to look up that column name as a value which is held in the column called reference_code
in tbl_reference_data
Here's the tbl_reference_data
table which contains the data glossary with example data:
(reference_def_id,
reference_def_name,
reference_def_created,
reference_def_last_updated,
dataset_category,
dataset_type,
reference_code,
reference_name,
reference_description,
reference_status,
reference_lang)
Example data:
('8f603ffe-6800-11ea-bc55-0242ac130003', 'Data Origin Identifiers', '17/03/2020 16:34', '17/03/2020 16:34', 'Reporting', 'data-glossary', 'reference_definition_name', 'Definition Name', 'This is the name of the reference data set related to the purpose of the reference definitions.','ACTIVE','EN')
Thanks, Matt