Re: SQL Syntax Queestion
From: Mark Woytus <mwoytus_at_divcomp.com>
Date: Wed, 10 Jun 1998 17:14:58 GMT
Message-ID: <357ebd13.13837257_at_news.dave-world.net>
Mark Woytus (w)309.888.8423 (f)309.888.8246 Diversified Computer Consultants
mwoytus_at_divcomp.com woytus_at_acm.org Received on Wed Jun 10 1998 - 19:14:58 CEST
Date: Wed, 10 Jun 1998 17:14:58 GMT
Message-ID: <357ebd13.13837257_at_news.dave-world.net>
On Tue, 9 Jun 1998 11:01:02 -0600, "Roger Loeb" <rloeb_at_martech.com>
wrote:
<snip>
>What I want to say is something like --
>
>Select * from Households where Households.LastName, Households.FirstName IN
>(Select LastName, FirstName from AnotherTable by LastName, FirstName having
>count (*) > 1);
>
>In other words, for any lastname+firstname combination that exists more than
>once in AnotherTable, I want to select the record for the same
>lastname+firstname combination from the "Household" table. However, this
>doesn't seem to do what I expect.
>
For matching multiple columns with a subselect, use parentheses.
select * from households
where (households.lastname, households.firstname) in
(select lastname, firstname from anothertable having count(*) > 1 group by lastname, firstname);
Mark Woytus (w)309.888.8423 (f)309.888.8246 Diversified Computer Consultants
mwoytus_at_divcomp.com woytus_at_acm.org Received on Wed Jun 10 1998 - 19:14:58 CEST