SQL Transact – Where IN clause
Just a tiny word, but what a difference IN makes to your transact statement. On this page we combine WHERE and IN to make a more sophisticated SQL filter.
Lesson 1 – Filtering companies in specific countries.
The situation is: You need to contact your customers buy only if they are in 4 Central European countries.
Note 1: What I like is the efficiency of using SQL’s IN rather than multiple select statements.
Note 2: The choice of round brackets to (enclose all the countries).
Note 3: Each country has its own set of single quotes and is separated from its neibour by a comma.
Note 4: Incidentally, we filtered the columns to just companyname and country.
Another SQL Transact condition: Where BETWEEN
On a completely different tack, you could try:
Guy’s Out Takes
If you like a challenge, troubleshoot this transact statement and see if you can correct the error.
SQL Transact Out Take 1
Why does this transact statement not execute?
Answer: What wee need is countRy not county.
SQL Transact Out Take 2
Why won’t this statement run?
Answer: The FROM clause should be on the line before the WHERE clause: here is the correct SQL Transact sequence.
WHERE unitprice BETWEEN 15 AND 25.