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

I am confused on how to use BETWEEN an LIKE in the same UNION query statement

SELECT Name FROM Fruit UNION SELECT Name FROM Vegetable WHERE Name BETWEEN LIKE A% AND L%;

2 Answers

Steven Parker
Steven Parker
231,269 Points

You can't combine LIKE and BETWEEN, but I'd guess you don't need either. You didn't show the instructions, but assuming they have asked you for names that start with A up through L, you can use an inequality test:

... WHERE name < 'N'

Also be sure to give each SELECT it's own WHERE clause.

Thank you! I actually ended up doing that exact thing.