Day 2

Quiz

1:Can you use wildcards with IN, as in this example?
select ProductName, UnitPrice
from Products
where ProductName in ('%tofu%', '%cereal%', '%grain%')
A1: No. The server will treat the wildcards (% characters) as literal characters and will try to find products whose name is literally '%tofu%' or '%cereal%'. To combine multiple wildcard searches, use OR to connect LIKE clauses:
select ProductName, UnitPrice
from Products
where ProductName like '%tofu%'
    or ProductName like '%cereal%'
    or ProductName like '%grain%'
2:When do you need to group conditions using parentheses?
A2: Parentheses are required when your WHERE clause consists of more than two conditions and there is a combination of OR and AND conjunctions.
3:In this query, is the ...

Get Sams Teach Yourself Transact-SQL in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.