Wrox Programmer Forums
BOOK: Beginning C# 2005 Databases
This is the forum to discuss the Wrox book Beginning C# 2005 Databases by Karli Watson; ISBN: 9780470044063
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning C# 2005 Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 16th, 2009, 11:57 AM
Authorized User
Join Date: Sep 2008
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default Query problem in Oracle 9i

I am having problem of understanding query in book of Oracle 9i, the query is this:

select empno,ename,sal
from emp
where sal>900
and ename between 'QUENTIN' and 'ZYRYRAB';

---------- ---------- ----------
7521 WARD 1250
7788 SCOTT 3000
7844 TURNER 1500

3 rows selected.

I want to know how 'QUENTIN' and 'ZYRYRAB' works, because I simply don’t get how'QUENTIN' and 'ZYRYRAB' eliminates KING which makes more money than WARD,SCOTT , TURNER the book says that KING’s last name does not fall between 'QUENTIN' and 'ZYRYRAB', 1st of all I have not yet seen last name or full name all I in the tables are just single names then what book is talking about last name? And also'QUENTIN' and 'ZYRYRAB' works I simply don’t get.
Could u plz help me understanding the above mention problem?
How to do programming?
Old July 16th, 2009, 04:58 PM
Friend of Wrox
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts


As the book says, King does not fall between Quentin and Zyryrab - these names are the last names of the employees.

If you were to remove the ename condition in the statment so you are just getting employees with sal > 900, then KING would appear.

Similarly, if you were to change the ename clause to get between 'ANDREWS' and 'VINCENT', you would get KING, SCOTT, TURNERin the results, but not WARD, as K (for KING) is between A (for Andrews) and V (for VINCENT) but W (for WARD) is not.
List the names in alphabetical order and it should be clearer

ANDREWS - start of range
VINCENT - end of range
WARD - out of range

Hope this makes sense
Old July 16th, 2009, 07:00 PM
Friend of Wrox
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts


In response to your question, I will reference "Boolean Algebra" or what is sometimes called "The Truth Table". In "Boolean Algebra" you will ALWAYS HAVE 1 of 2 RESPONSES: 1 or 0; T(rue) or F(alse); M(ale) or F(emale); O(n) or O(ff), etc.
The Truth Table is as follows, whih I will use T=True and F=False:
  • CASE= > the "AND" Condition, where A,B = an expression or value:
    • If A is T AND B is T, then A AND B are T. If A=1 AND B=1, then A and B are T(rue);
    • If A is F AND B is F, then A AND B are T.
  • Evaluation of Expressions in the "AND" operand MUST Evaluate to TRUE, which means BOTH expressions MUST evaluate to TRUE or BOTH expressions MUST evaluate to FALSE;
  • When either of the two expressions evaluate to TRUE or FALSE, then BOTH in the AND Condition are FALSE.
In your example starting with the WHERE-Clause: WHERE sal >900 AND ename between 'QUENTIN' and 'ZYRYRAB'
  • Evaluation 1, from left to right (no parentheses to state otherwise). Let A= sal>900. In this evaluation the employee KING was a part of this group, which made this evaluation TRUE;
  • AND is the operand;
  • Evaluation 2, Let B= ename between 'QUENTIN' and 'ZYRYRAB', For the evaluation of this statement excludes KING becuase the ename starts with the english alphabet letter "K" and this exclusion makes the evaluation also TRUE;
  • Back to the Truth Table: If A=True and B=True, then A AND B are True,which yeilds
    • 7521 WARD 1250, 788 SCOTT 3000, 7844 TURNER 1500
  • The Truth Table also considers the "OR" Operand and the "! - NOT" Operands, but they were not your question.
Hope this helps.
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem while running IIS 6 with Oracle 9i Hidayatullakhan Oracle ASP 0 September 16th, 2007 04:43 AM
Sql Server 2000 vs Oracle 9i - performance problem sniegu Hibernate 2 January 27th, 2006 12:10 PM
Installation of Oracle 9i sreechand_b Oracle 4 September 13th, 2005 08:10 AM
Help -- About Oracle 9I and Tuxedo Performance jamestong Oracle 0 May 19th, 2005 03:11 AM
Oracle 9i OCI knguyen Oracle 0 August 12th, 2003 07:29 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.