List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:June 29 2006 9:30pm
Subject:Re: Distinct from two tables
View as plain text  
Mark Steudel wrote:
> Is there a way get distinct results between pf and sf?
>
> Select
> pf.name,
> sf.name
> From
> tblpropertyfeatures,
> tblsuitefeatures
> Inner Join tblfeatures AS pf ON tblpropertyfeatures.featureid = pf.id
> Inner Join tblfeatures AS sf ON tblsuitefeatures.featureid = sf.id
>   
Do you mean ...

SELECT 
  MIN(TableName) as TableName, id, name
FROM (
  SELECT 'Table a' as TableName, a.id, a.name
  FROM tblpropertyfeatures
  UNION ALL
  SELECT 'Table b' as TableName, b.id, b.name
  FROM tblsuitefeatures
) AS tmp
GROUP BY id, name
HAVING COUNT(*) = 1
ORDER BY ID;

PB

> -----------------------------------------
> Mark Steudel
> NetRiver
> Web and Application Developer
> 555 Dayton St.
> Suite A
> Edmonds, WA 98020
> w: http://www.netriver.net
> p: 425.741.7014
>
>
>
>
>   

Attachment: [text/html]
No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.394 / Virus Database: 268.9.7/379 - Release Date: 6/29/2006
Thread
Distinct from two tablesMark Steudel29 Jun
  • Re: Distinct from two tablesPeter Brawley29 Jun