Re: Selecting data from one table based on conditions in another table
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 02 Feb 2006 22:43:51 +0100
On Thu, 2 Feb 2006 11:50:40 -0800, "John Steen"
<moderndads(nospam)@hotmail.com> wrote:
I'm used to doing simple queries from individual tables, so I hope someone
can help with this.
I need to select unique data from a column in table1 based on the value of a
column in table2. The data in the column of table1 is not all unique, so I
also need to filter out extra occurrances of of the data. So if the name
JOHN SMITH appears 27 time in the column in table 1, I only want to return
one instance of the name.
Thanks in advance.
Hi John,
Based on your very vague narrative, here's a shot in the dark:
SELECT DISTINCT Table1.SomeColumn
FROM Table1
INNER JOIN Table2
ON Table2.LinkingColumn = Table1.LinkingColumn
WHERE Table2.OtherColumn = @WhateverYouLookFor
If this is not what you want, then please post better specification. A
good explanation of what you need to post and how you can assemble it is
to be found at www.aspfaq.com/5006.
--
Hugo Kornelis, SQL Server MVP
.
- Prev by Date: Re: Changing Ordering
- Next by Date: Re: Changing Ordering
- Previous by thread: Re: Changing Ordering
- Next by thread: Re: Date Selection
- Index(es):
Relevant Pages
|
|