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!

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

how to limit results in a string range [e.g. show all names with starting letter from 'a' to 'k']?

--my query, the challenge task says this is not the solution Thanks for the help.

select name from fruit union select name from vegetable where name like 'a%' or name like 'b%' or name like 'c%' or name like 'd%' or name like 'e%' or name like 'f%' or name like 'g%' or name like 'h%' or name like 'i%' or name like 'j%' or name like 'k%' order by name asc ;

2 Answers

That seems like a lot of work. You can use greater than on less than symbols with the alphabet to specify a range.

i have the solution: i should write the where clause for each table

the correct query: select name from fruit where name like 'a%' or name like 'b%' or name like 'c%' or name like 'd%' or name like 'e%' or name like 'f%' or name like 'g%' or name like 'h%' or name like 'i%' or name like 'j%' or name like 'k%' union select name from vegetable where name like 'a%' or name like 'b%' or name like 'c%' or name like 'd%' or name like 'e%' or name like 'f%' or name like 'g%' or name like 'h%' or name like 'i%' or name like 'j%' or name like 'k%' order by name asc ;