I've got a settings table constructed with 'category' determining different products, 'varname' being the variable name, and 'info' being the value of the setting.
so, for instance,
select top 6 category, varname, info
from settings_table
where NODE_NAME='HTT-COMM-A'
and section='Module Settings'
and category in ('ProductA', 'ProductB')
order by varname
results in :
category varname info ProductB WEB_ACCESS_ALLOW NO ProductA WEB_ACCESS_ALLOW NO ProductB WEB_ACCESS_BLOCK YES ProductA WEB_ACCESS_BLOCK YES ProductB WEB_ACCOUNT_DETAIL NO ProductA WEB_ACCOUNT_DETAIL YES
I'd like to generate a simple list of differences between the values when category='ProductA' and 'ProductB'. I can think of a number of ways to do this with a temporary table, or by a number of subselects (for instance, this painful one) :
select a.category, a.varname, a.info , b.category, b.info
from (select category, varname, info, description
from settings_table
where category = 'ProductA') as a,
(select category, varname,info, description
from settings_table
where category = 'ProductB') as b
where a.varname=b.varname and a.info != b.info
but the above method (at least) fails when there's a varname in b that isn't in a. (Any solutions should fix this problem, any differences in varnames between a and b should be represented as well.)
This isn't a hard problem to solve in a kludgy way, but I wonder if there's a 'right way' to do this elegantly, without the horrid sub-selects or without the caveats above.
This is more SQL agnostic, but this particular table is in a MSSQL server.
Thanks, Rk