var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Is this possible?
I'm still pretty inexperienced with SQL so this might be a dumb or easy question, but here goes....
Is it possible to return a value from a query when the result is based over multiple rows?
For example, I have a table (TABLE_A) containing the following rows:
All I know for my select is the VALUE must contain both 6 AND 7.
So, I need a query that will return ID 1 only as that is the only one that has a value of both 6 and 7.
Is this possible?
select ID from table_a a
where exists (select 1 from table_a b
where a.ID = b.ID
and b.value = 6)
and exists (select 1 from table_a c
where a.ID = c.ID
and c.value = 7)
WHERE value IN ( 6,7 )
HAVING COUNT(*) = 2
I especially like the last answer as it's easier to expand if there are 3 criteria
and ~much~ easier if you need to do something like "has at least 3 of the following 5" ...
Originally Posted by damiantaylor
sure as heck can't do this one easily with joins
WHERE value IN ( 6,7,8,9,37 )
HAVING COUNT(*) >= 3
This a great info for newbie. Thanks