Hi All,
This is going to be quite tricky to explain, but hang in there please.....
Ok, so we are using a third party system that uses key value pairs within a database table. The basic structure is ID, SubID, Name, Value. There are multiple subID's which build up meta data about a specific thing. One of these fields is a comma seperated list of values. Now what i need to be able to do is to return all of the values from the table, but to then use the values of the comma seperated list within the query itself as part of a where statement.
At the moment because of the format of the table i have used a temporary table which is populated by various small queries and i am then using this temporary table as my base for my search.
The issue that i have is referencing this this comma list within my query.
what i ahve at the moment is:
creation of temp table
select a,b,c
from tableA
where ID IN (
SELECT ID
from tempTable
where fieldA = '%aa%'
loop over commaList
AND fieldA = '%commaListValue%'
end
)
i have tried refernecing it via the tablename.fieldname convention (errored), creating a function that will return the value (but i couldn't reference the ID i needed to identify the commalist uniquely) and various other things, now i am here hoping someone out there can help out with this and stop my brain melting.
I would have posted the code, but there is about 173 lines of it
Any help appreciated
Thanks
Tony
This is going to be quite tricky to explain, but hang in there please.....
Ok, so we are using a third party system that uses key value pairs within a database table. The basic structure is ID, SubID, Name, Value. There are multiple subID's which build up meta data about a specific thing. One of these fields is a comma seperated list of values. Now what i need to be able to do is to return all of the values from the table, but to then use the values of the comma seperated list within the query itself as part of a where statement.
At the moment because of the format of the table i have used a temporary table which is populated by various small queries and i am then using this temporary table as my base for my search.
The issue that i have is referencing this this comma list within my query.
what i ahve at the moment is:
creation of temp table
select a,b,c
from tableA
where ID IN (
SELECT ID
from tempTable
where fieldA = '%aa%'
loop over commaList
AND fieldA = '%commaListValue%'
end
)
i have tried refernecing it via the tablename.fieldname convention (errored), creating a function that will return the value (but i couldn't reference the ID i needed to identify the commalist uniquely) and various other things, now i am here hoping someone out there can help out with this and stop my brain melting.
I would have posted the code, but there is about 173 lines of it
Any help appreciated
Thanks
Tony