home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!doc.ic.ac.uk!agate!ucbvax!mtxinu!sybase!robert
- From: robert (Robert Garvey)
- Newsgroups: comp.databases.sybase
- Subject: Re: Comparing two columns in two tables
- Keywords: not exists
- Message-ID: <27155@sybase.sybase.com>
- Date: 15 Dec 92 20:33:59 GMT
- References: <1992Dec3.233316.25194@muug.mb.ca>
- Sender: news@Sybase.COM
- Distribution: comp.databases.sybase
- Organization: Emeryville Tupleware, Party Planning Division
- Lines: 21
-
- In article <1992Dec3.233316.25194@muug.mb.ca>, dmenns@muug.mb.ca (Darren Enns) writes:
- |> I hope someone could suggest some nifty SQL to solve a
- |> situation I have. assume two tables with two columns each -- I want to
- |> verify that all column pairs in one table occur at least once as a pair
- |> in the other table.
-
- |> It seems to me that
- |> there should be a way to do this in SQL -- all I can think of is the code
- |> necessary to prove that a violation exists, but not *where* it does.
- |> Thanx for any help.
-
- SELECT x.e, x.f FROM x
- WHERE NOT EXISTS ( SELECT * FROM y
- WHERE y.e = x.e
- AND y.f = x.f )
-
- --
- Robert Garvey robert@sybase.com {sun,lll-tis,pyramid,pacbell}!sybase!robert
- Sybase, Inc 6475 Christie Ave Emeryville, CA 94608-1010
-
- If Sybase were to pay employees for their opinions, they couldn't afford me.
-