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

Odane Williams
Odane Williams
6,692 Points

I followed all the examples but I'm getting an error that says the query is not returning through A and K.

Is it my syntax?

SELECT Name FROM Fruit WHERE Name BETWEEN "A" AND "K" UNION SELECT Name FROM Vegetable WHERE Name BETWEEN "A" AND "K" ORDER BY Name;

Steven Parker
Steven Parker
231,236 Points

Show your complete query so we can see.

1 Answer

Steven Parker
Steven Parker
231,236 Points

You're close, but BETWEEN "A" AND "K" would not include any names that begin with "K" unless the name was just the single letter "K" itself.

You might want to make use of an inequality comparison, since they work on dictionary order when used with strings.

Also, I don't think the task asks you to ORDER the results in any particular way.

Odane Williams
Odane Williams
6,692 Points

Thank you. I solved it by using WHERE Name < "L". Could I have used LIKE "A%" AND "K%" also?

Steven Parker
Steven Parker
231,236 Points

That expression isn't complete, but even if you used WHERE Name LIKE "A%" OR Name LIKE "K%" that would only give you names starting with "A" and "K" and nothing in between. Combining with AND would produce no output, because no name could start with both letters.