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

Jessica Carey
Jessica Carey
690 Points

SQL command error

Find all the matches in the results table where "Hessle" was playing away as the away team and if they played on or after October 1st 2015. Date format is "YYYY-MM-DD".

My command: SELECT * FROM results WHERE "Hessle" = away_team AND away_team >= "2015-10-01";

Paul Pepe
Paul Pepe
1,900 Points

WHERE "Hessle" = away_team

should it not be WHERE away_team = "Hessle"

?

Steven Parker
Steven Parker
231,248 Points

In an equality comparison, the order of the comparitors is not important.

2 Answers

Steven Parker
Steven Parker
231,248 Points

It looks like you're comparing the wrong field.

Your WHERE clause combines two comparisons, and the the second one is for a date. But you're using the same field in both comparisons. You probably want the second comparison to be made with the played_on field instead:

SELECT * FROM results WHERE "Hessle" = away_team AND played_on >= "2015-10-01";

In future questions, remember to provide a link to the course page you are working with.

Jessica Carey
Jessica Carey
690 Points

Thanks Steven, after taking a break and coming back to the problem, I realized I completely left out The played_on column.