Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > BOOK: Beginning C# 2005 Databases
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 16th, 2009, 11:57 AM
Authorized User
Points: 350, Level: 6
Points: 350, Level: 6 Points: 350, Level: 6 Points: 350, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2008
Location: , , Pakistan.
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?
  #2 (permalink)  
Old July 16th, 2009, 04:58 PM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Sep 2005
Location: London, , United Kingdom.
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
  #3 (permalink)  
Old July 16th, 2009, 07:00 PM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: May 2005
Location: OKC, OK, USA.
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.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 02:18 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.