home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!newsserver.jvnc.net!louie!eplrx7!eplrx7.es.dupont.com!hanafey
- From: hanafey@eplrx7.es.dupont.com (Mike Hanafey)
- Subject: Re: Sybase 4.9.1 Returns the Wrong Rows
- Message-ID: <1993Jan22.103657.13562@eplrx7.es.duPont.com>
- Keywords: SQL
- Sender: news@eplrx7.es.duPont.com (News Admin Account)
- Nntp-Posting-Host: eplrx7
- Organization: DuPont Central Research & Development
- References: <1993Jan19.134419.27020@eplrx7.es.duPont.com> <1jju7fINNdtl@gazette.bcm.tmc.edu> <1993Jan20.183702.14919@eplrx7.es.duPont.com> <1jl68m$2l8@agate.berkeley.edu>
- Date: Fri, 22 Jan 1993 10:36:57 GMT
- Lines: 46
-
- After getting a few responses to my initial posting, I still believe Sybase returns the
- wrong result for the query below. I think some confusion comes from it appearing that
- the select in the "where" clause is a join. In fact it is a correlated subquery (table
- "c" is not listed in the "from" clause of the second select). For each row in "c", the rows
- in "b" that have the same value in b.c1 as the current row's c.c1 are counted, and if this
- count is > 1 the row is selected. Since "b" has no duplicates in "c1", no rows should ever be
- selected, regardless of what is in "c".
-
- I tried this same query on VAX rdb, and got the expected result of "0 rows selected".
-
- The Sybase result is repeated below:
-
- 1> select c.c1 from c where (select count(*) from b where b.c1 = c.c1) > 1
- 2> go
- c1
- -----------
- 2
- 2
- 3
- 3
- 3
- (5 rows affected)
-
-
- 1> select * from c
- 2> go
- c1
- -----------
- 1
- 2
- 2
- 3
- 3
- 3
- (6 rows affected)
-
- 1> select * from b
- 2> go
- c1 c2
- ----------- -----------
- 1 0
- 2 0
- 3 0
-
- (3 rows affected)
- --
-