5-4. Perform an experiment to determine the precedence in a query with three conditions linked by AND and OR. Find out w
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
5-4. Perform an experiment to determine the precedence in a query with three conditions linked by AND and OR. Find out w
SQL> SELECT *2 FROM rearp.Section;
SECTION_ID COURSE_NUM SEMESTER YEAR---------- ------------------------ ------------------ ------INSTRUCTOR BLDG ROOM------------------------------ ---------- ----------85 MATH2410 FALL 14KING 36 123
86 MATH5501 FALL 14EMERSON 36 123
87 ENGL3401 FALL 15HILLARY 13 101
SECTION_ID COURSE_NUM SEMESTER YEAR---------- ------------------------ ------------------ ------INSTRUCTOR BLDG ROOM------------------------------ ---------- ----------88 ENGL3520 FALL 16HILLARY 13 101
89 ENGL3520 SPRING 16HILLARY 13 101
90 COSC3380 SPRING 16HARDESTY 79 179
SECTION_ID COURSE_NUM SEMESTER YEAR---------- ------------------------ ------------------ ------INSTRUCTOR BLDG ROOM------------------------------ ---------- ----------91 COSC3701 FALL 1479 179
92 COSC1310 FALL 16ANDERSON 79 179
93 COSC1310 SPRING 16RAFAELT 79 179
SECTION_ID COURSE_NUM SEMESTER YEAR---------- ------------------------ ------------------ ------INSTRUCTOR BLDG ROOM------------------------------ ---------- ----------94 ACCT3464 FALL 15RODRIGUEZ 74
95 ACCT2220 SPRING 15RODRIQUEZ 74
96 COSC2025 FALL 17RAFAELT 79 179
5-4. Perform an experiment to determine the precedence in a query with three conditions linked by AND and OR. Find out whether AND, OR, or left-to-right take precedence? Use statements like this (actual attribute names may be found using "DESC Student"): Run this query: SELECT FROM WHERE Student stno < 100 AND major = 'COSC' OR major = 'ACCT'; Then run the following two queries and answer whether the non-parenthesized statement gives you: SELECT FROM WHERE Student (stno < 100 AND major = 'COSC') OR major = 'ACCT';
or: SELECT FROM WHERE Student stno < 100 AND (major = 'COSC' OR major = 'ACCT'); What happens if you put the OR first instead of the AND and run the query without parentheses? 131