Databases Querying Relational Databases Set Operations Set Operations

Query works in SQL Playground but fails in quiz

2 tables fruit and vegetables. Create a list of all fruits and vegetables starting with letter A thru K

My solution: SELECT Name FROM Fruit WHERE Name >= 'A' AND Name <= 'K' UNION SELECT Name FROM Vegetable WHERE Name >= 'A' AND Name <= 'K';

2 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,188 Points

Would your query select:

Kale

Kiwifruit

Kohlrabi

Kohlrabi Greens

Kumquat

or just the letter K?

It retrieves all names starting with A through K. So, yes, for K - it retrieves all of the above starting with letter K

Okay, Here is the answer: SELECT Name FROM Fruit WHERE Name > 'A%' AND Name < 'L%' UNION SELECT Name FROM Vegetable WHERE Name > 'A%' AND Name < 'L%'; The issue was with >= operator; = Doesn't work and hence the issue.