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

Filtering By Comparing Values

It says:

"Did you select from the 'results' table?"

SELECT * FROM results WHERE home_score < 10;

Also this has the same type of error:

SELECT * FROM users WHERE last_name = "Hinkley" OR "Pettit";

2 Answers

Andrew Winkler
Andrew Winkler
37,739 Points

I just went to the question, copied and pasted your code in, and re-created the same error code. Yes the error code of Did you select from the 'results' table? is wrong because your code did reference the results table, but try rereading the question.

Filtering by Comparing Values - Challenge Task 2 of 3

We still using the sports team's database. In the results table we have the columns id, home_team, home_score, away_team, away_score, played_on. Find all results where the away team's score is lower than 10.

-- the challenge is looking for the away team's score, not the home team's score.
SELECT * FROM results WHERE away_score < 10;

In your second question question when I pasted your code, I got the following error code: Did you select from the `users` table and test the `last_name` column? This is also confusing, because you did select the correct table and column, however the method by which you selected them is incomplete is incomplete.

Filtering on More than One Condition - Challenge Task 2 of 2

Now we're in the e-commerce database. In the users table we have the columns id, username, password, first_name and last_name. Find all users with either the last name "Hinkley" or "Pettit"

-- you had 
SELECT * FROM users WHERE last_name = "Hinkley" OR "Pettit";
-- these are not 2 complete clauses combined by an OR operator

-- the correct command fully completed is:
SELECT * FROM users WHERE last_name = "Hinkley" OR last_name = "Pettit"

Keep working at it. The error messages on team treehouse are not precise, but often neither are there messages in IDEs. Happy coding!

Thanks for that. One of my major flaws is not reading the question properly...the amount of questions on my maths test I got wrong because of that...Uggh.

Anyway thanks for the help and detailed answer!

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey there,

could you specify the code challenge you can't pass? For the second SQL statement you posted the problem is that you have to specify last_name for both comparisons, not just the first one.

Like so:

SELECT * FROM users WHERE last_name = "Hinkley" OR last_name = "Pettit";

It was the filtering by comparing values in the second stage of SQL basics, the fourth video/task. thanks