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

Hi Team, I ran the query to get the distinct name from Fruit and Vegetable tables having name starting with A through K

select name from Fruit where name like '[A-Z]%' union select name from Vegetable where name like '[A-Z]%';

Above query seems good to me but not working, Could you please have a look into this?

2 Answers

Andreas Frost Nordstrøm-Hansen
Andreas Frost Nordstrøm-Hansen
2,443 Points

Remember you need between A and K. So you need to set it to "A" AND "L".

It will not count K as in between. So you have to make it L instead.

So this should work.

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

Thank you!

Andreas Frost Nordstrøm-Hansen
Andreas Frost Nordstrøm-Hansen
2,443 Points

Remember to vote best answer if it worked, so ohter people can find it quickly :)

Good Luck!

Andreas Frost Nordstrøm-Hansen
Andreas Frost Nordstrøm-Hansen
2,443 Points

You have to use the BETWEEN keyword here.

Try with that. Reply again if you dont know what the correct code is, i can paste that aswell. But try and give it a go first.