all groups > sql server mseq > february 2006 >
You're in the

sql server mseq

group:

Selecting data from one table based on conditions in another table


Selecting data from one table based on conditions in another table John Steen
2/2/2006 11:50:40 AM
sql server mseq:
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.
--
John Steen
Re: Selecting data from one table based on conditions in another table Hugo Kornelis
2/2/2006 10:43:51 PM
On Thu, 2 Feb 2006 11:50:40 -0800, "John Steen"
[quoted text, click to view]

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.

--
Re: Selecting data from one table based on conditions in another t John Steen
2/7/2006 1:39:28 PM
Thanks much, Hugo, the query seems to have worked.

--
John Steen
remove (nospam) from e-mail address to send me a message


[quoted text, click to view]
AddThis Social Bookmark Button