Newsgroups: comp.databases
Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!usenet.ins.cwru.edu!ncoast!allbery
From: allbery@NCoast.ORG (Brandon S. Allbery KB8JRR/KT)
Subject: Re: a question regarding a query using Unify 4.0 SQL
Reply-To: allbery@ncoast.ORG (Brandon S. Allbery KB8JRR/KT)
Organization: North Coast Public Access *NIX, Cleveland, OH
Date: Wed, 15 Aug 90 23:14:35 GMT
Message-ID: <1990Aug15.231435.2177@NCoast.ORG>
Followup-To: comp.databases
References: <201603@hrc.UUCP>

As quoted from <201603@hrc.UUCP> by dan@hrc.UUCP (Dan Troxel):
+---------------
| 	select rolodex.entry_num from rolodex
| 		where rolodex.referral_source = 'POST*'
| 		and rolodex.entry_num ^=
| 		select rolnotes.rol_linker from rolnotes
| 			where rolnotes.rol_linker = rolodex.entry_num/
+---------------

This joins every row in rolodex to every row in rolnotes *except* the ones
which would join if the comparison were "=" in the subquery.

What you want is:

	select
	    rolodex.entry_num
	from
	    rolodex
	where
	    rolodex.referral_source = 'POST*'			and
	    0 ^=
		select
		    count(*)
		from
		    rolnotes
		where
		    rolnotes.rol_linker = rolodex.entry_num
	    ;
	/

(The above is the style we use at Telotech; your mileage, of course, will vary
with respect to indentation, line breaks, optional syntax, etc.)

This can be slow, but will be quite fast if there is an explicit relationship
between rolodex.entry_num and rolnotes.rol_linker.

++Brandon
-- 
Me: Brandon S. Allbery			    VHF: KB8JRR/KT on 220 (soon others)
Internet: allbery@NCoast.ORG		    Delphi: ALLBERY
uunet!usenet.ins.cwru.edu!ncoast!allbery    America OnLine: KB8JRR
