Q160 Examine the description of the BOOKS_TRANSACTIONS table:
Name Null? Type
================================== =========== ==========================
TRANSACTION_ID NOT NULL VARCHAR2(6)
TRANSACTION_TYPE VARCHAR2(3)
BORROWED_DATE DATE
BOOK_ID VARCHAR2(6)
MEMBER_ID VARCHAR2(6)
Examine this partial SQL statement:
SELECT * FROM books_transactions
Which two WHERE conditions give the same result?
- A) WHERE borrowed_date = SYSDATE AND (transaction_type = ‘RM’ AND member_id = ‘A101’ OR member_id = ‘A102’);
- B) WHERE borrowed_date = SYSDATE AND (transaction_type = ‘RM’ AND (member_id = ‘A101’ OR member_id = ‘A102’));
- C) WHERE borrowed_date = SYSDATE AND (transaction_type = ‘RM’ OR member_id IN (‘A101’,‘A102’));
- D) WHERE (borrowed_date = SYSDATE AND transaction_type = ‘RM’) OR member_id IN (‘A101’,‘A102’);
- E) WHERE borrowed_date = SYSDATE AND transaction_type = ‘RM’ OR member_id IN (‘A101’,‘A102’);
Answer: D,E
Table 6-1 SQL Condition Precedence
Type of Condition Purpose
SQL operators are evaluated before SQL conditions See Operator Precedence
=, !=, <, >, <=, >=, comparison
IS [NOT] NULL, LIKE, [NOT] BETWEEN, [NOT] IN, EXISTS, IS OF type comparison
NOT exponentiation, logical negation
AND conjunction
OR disjunction