home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / database / sybase / 719 < prev    next >
Encoding:
Text File  |  1993-01-22  |  2.0 KB  |  60 lines

  1. Newsgroups: comp.databases.sybase
  2. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!newsserver.jvnc.net!louie!eplrx7!eplrx7.es.dupont.com!hanafey
  3. From: hanafey@eplrx7.es.dupont.com (Mike Hanafey)
  4. Subject: Re: Sybase 4.9.1 Returns the Wrong Rows
  5. Message-ID: <1993Jan22.103657.13562@eplrx7.es.duPont.com>
  6. Keywords: SQL
  7. Sender: news@eplrx7.es.duPont.com (News Admin Account)
  8. Nntp-Posting-Host: eplrx7
  9. Organization: DuPont Central Research & Development
  10. 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>
  11. Date: Fri, 22 Jan 1993 10:36:57 GMT
  12. Lines: 46
  13.  
  14. After getting a few responses to my initial posting, I still believe Sybase returns the
  15. wrong result for the query below. I think some confusion comes from it appearing that
  16. the select in the "where" clause is a join. In fact it is a correlated subquery (table
  17. "c" is not listed in the "from" clause of the second select). For each row in "c", the rows
  18. in "b" that have the same value in b.c1 as the current row's c.c1 are counted, and  if this
  19. count is > 1 the row is selected. Since "b" has no duplicates in "c1", no rows should ever be
  20. selected, regardless of what is in "c".
  21.  
  22. I tried this same query on VAX rdb, and got the expected result of "0 rows selected".
  23.  
  24. The Sybase result is repeated below:
  25.  
  26.      1> select c.c1 from c where (select count(*) from b where b.c1 = c.c1) > 1
  27.      2> go
  28.       c1          
  29.       ----------- 
  30.                 2 
  31.                 2 
  32.                 3 
  33.                 3 
  34.                 3 
  35.      (5 rows affected)
  36.  
  37.  
  38.      1> select * from c
  39.      2> go
  40.       c1          
  41.       ----------- 
  42.                1 
  43.                2 
  44.                2 
  45.                3 
  46.                3 
  47.                3 
  48.      (6 rows affected)
  49.  
  50.      1> select * from b
  51.      2> go
  52.       c1          c2          
  53.       ----------- ----------- 
  54.                1           0 
  55.                2           0 
  56.                3           0 
  57.  
  58.      (3 rows affected)
  59. -- 
  60.