Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Avoid selecting duplicate rows


Message #1 by "kofi karikari" <kofikarikari@h...> on Mon, 07 Jan 2002 12:12:01 +0000
I assume you mean select all rows from table1 and only those rows in table2
where MYID isn't found in table1?
(it's pretty hard to select rows from table2 where there are not rows in
table2... or is it easy...)

I guessed at this:
Table1                    Table2
-------                    -------
1                                4
2                                5
3                                6
4                                7
5                                8


SELECT MYID FROM TABLE1
UNION
SELECT MYID FROM TABLE2 WHERE MYID NOT IN
(SELECTD MYID FROM TABLE1)

And the query returns
MyId
--------
1
2
3
4
5
6
7
8

I hope this has helped.  It was a good exercise for me as well.

Yours,
AR

----- Original Message -----
From: "kofi karikari" <kofikarikari@h...>
To: "sql language" <sql_language@p...>
Sent: Monday, January 07, 2002 5:12 AM
Subject: [sql_language] Avoid selecting duplicate rows


>
> I have two tables, table1 and table2 with the rows in both tables uniquely
> identified by MYID. How do I select all the rows in table1 and the rows in
> table2 which are not in table2?
> Thanks for your response
>
>
>
>
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
$subst('Email.Unsub').
>

  Return to Index