I'm reading a book Sams Teach Yourself SQL in 10 minutes (although its impossible to read in 10 minutes) and in the answer in one of the exercises confuses me, im not sure whether the answer provided is correct. (Hour 8 Exercise item #2, answer is in the appendix)
Write a SELECT statement that returns customer IDs and customer names (alpha order) for customers who live in Indiana, Ohio, Michigan, and Illinois, with names that begin with the letters A or B.
SELECT CUST_ID, CUST_NAME, CUST_STATE
FROM CUSTOMER_TBL
WHERE CUST_STATE IN ('IN', 'OH', 'MI', 'IL')
AND CUST_NAME LIKE 'A%'
OR CUST_NAME LIKE 'B%'
ORDER BY CUST_NAME;
wont this query return customer IDs and customer names for customers whos name start with the letter B but do not live in the states mentioned?
shouldn't it be
SELECT CUST_ID, CUST_NAME, CUST_STATE
FROM CUSTOMER_TBL
WHERE CUST_STATE IN ('IN', 'OH', 'MI', 'IL')
AND (CUST_NAME LIKE 'A%' OR CUST_NAME LIKE 'B%')
ORDER BY CUST_NAME;