Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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.