home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / database / 6383 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  1.6 KB

  1. Xref: sparky comp.databases:6383 comp.databases.theory:411 comp.databases.oracle:1409
  2. Newsgroups: comp.databases,comp.databases.theory,comp.databases.oracle
  3. Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!alberta!isagate!edm.isac.ca!darius
  4. From: darius@edm.isac.ca (Darius S. Naqvi)
  5. Subject: Re: Is this a bug or a limitation of the SQL language
  6. Organization: ISA Corporation, Edmonton, AB
  7. Date: Wed, 26 Aug 92 16:26:06 GMT
  8. Message-ID: <1992Aug26.162606.1899@edm.isac.CA>
  9. References: <1992Aug23.074048.16681@prism.poly.edu>
  10. Sender: news@edm.isac.CA (News daemon pseudo-user account)
  11. Lines: 33
  12.  
  13. In article <1992Aug23.074048.16681@prism.poly.edu> sjha@prism.poly.edu (Salil Kumar Jha) writes:
  14. >I tried to do this query in Oracle and DB2 and both failed. I know its
  15. >not allowed but why not?
  16. >
  17. >Assume the use of the classic oracle emp table
  18. >
  19. >select * from emp 
  20. >where salary between
  21. >(select salary from emp where ename = 'Larry')
  22. >and
  23. >(select salary from emp where ename = 'John')
  24. >
  25. >Isnt this the best way of finding all people whose salaries lie between those
  26. >of Larry and John (without knowing whose is larger)
  27. >
  28. >sjha@prism.poly.edu
  29. >
  30.  
  31. Even if the syntax were allowed, you would still have to know that
  32. John's salary were greater than or equal to Larry's, because
  33.  
  34.     where salary between x and y
  35.  
  36. is simply an abbreviation for
  37.  
  38.     where salary >= x and salary <= y
  39.  
  40. If x > y, the where clause will always fail, so you get no rows
  41. selected.
  42. -- 
  43. Darius S. Naqvi              mail at work: darius@edm.isac.ca
  44. ISA Corp.                    mail at home: darius%naqvi.uucp@isac.ca
  45. Edmonton, Alberta, Canada           phone: (403) 420-8081 
  46.