Michael Nanni6,605 Points
How do I filter query results between a range of starting letters?
SELECT Fruit.Name FROM Fruit UNION SELECT Vegetable.Name FROM Vegetable WHERE Name <= 'K%';
I know there's something I'm missing about this challenge, but why isn't the above acceptable?
I've tried with the WHERE clause after both SELECT statements but that is incorrect as well. I'm not sure which operator works best for a range of starting letters. BETWEEN? LIKE?
Thanks in advance for any help.
alastair cooper25,424 Points
select employee_name from employees where employee_name LIKE 'A%' OR employee_name LIKE 'B%'
That is a quick way if your range is 2 or 3 letters
if you have a large range (ie A-M) then there is probably a better way
something like this...
SELECT * FROM Employee WHERE Name LIKE '[A-E]%';
The exact syntax will depend on version of SQL (mySql, Sql Server, etc)
Hope this helps