var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: SQL Query Help
I am trying to retrieve distinct ClientID's that match more than 1 item for example my query is currently
The Table structure example is
Select distinct ClientID from ClientRegs where RegionID = 1 and RegionID = 28
So I want the above query to return only 222 because it is the only client id that has a record for RegionID 1 and 28.
The above query doesn't work because the RegionID column will never be both 1 and 28 on the same record.
I've also tried
This query does not work because it will return 444 and 222.
Select distinct ClientID from ClientRegs where RegionID = 1 or RegionID = 28
Does anyone know if what I'm trying to do is possible and how it would be done?
Why not just run id dstinct by the clientID and sort it.
Select distinct ClientID from ClientRegs where RegionID => 1 .and. RegionID = 28 0
Select distinct ClientID from ClientRegs where RegionID >= 1 and RegionID = 28
That still returns all ClientID's that have either a 1 or a 28 not ClientID's that have records for both 1 and 28
use a sub query
---if there are fewer records
Select distinct ClientID from ClientRegs where RegionID = 1 and ClientID in
(select ClientID from ClientRegs where RegionID = 28)
----if there are more records
Select distinct a.ClientID
from ClientRegs a , ClientRegs b
where a.ClientID = b.ClientID
and a.RegionID <> b.RegionID
and a.RegionID = 1
and b.RegionID = 28
Thanks C Nag I used your first example and
that worked like a charm. I was starting to get worried.