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

Fahri Can
Fahri Can
9,921 Points

Why is my query wrong?

SELECT name FROM fruit WHERE name LIKE '[^A-Ka-k]%' UNION SELECT name FROM vegetable WHERE name LIKE '[^A-Ka-k]%';

There are two tables Fruit and Vegetable table. The Fruit table has a FruitID and a Name column and the Vegetable table has a VegetableID and Name column. Create a list of all fruits and vegetables starting with the letters A through K . In other words all fruit and vegetables that don't start with the letter L to Z.

2 Answers

Hi Fahri,

I think the code challenges are running on SQLite and it doesn't look like the ^ is supported in patterns.

You can make your condition name < 'L'

This would give you back all names that would come before 'L' in the dictionary.

Fahri Can
Fahri Can
9,921 Points

Thank you, Jason!

I typically use % on a day to day basis so ^ is new to me, but it looks like you are actually filtering out A-K and a-k. See here for more https://msdn.microsoft.com/en-us/library/ms179859.aspx or below from that link.

[^] Any single character not within the specified range ([^a-f]) or set ([^abcdef]). WHERE au_lname LIKE 'de[^l]%' all author last names starting with de and where the following letter is not l.