Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases

Mia Lee
Mia Lee
572 Points

How do I write a SQL statement for the below

We're back in the sports team database. There's a results table with the columns id, home_team, home_score, away_team, away_score and played_on . Find all the matches in the results table where "Hessle" was playing away as the away team and their score was above 18 points.

5 Answers

Ari Misha
Ari Misha
19,286 Points

Hiya Mia! The question couldnt be more clear and concise. We need to show "all" columns from the "result" table, "WHERE" "Hessle" was playing for "away_team" "AND" the "away_score" was more than "18 points". I hope this must be enough to steer you to the right path. If not , post back and ask away without hesitation. Happy Coding. (:

Rhys Kearns
Rhys Kearns
4,976 Points
SELECT * FROM TableName
WHERE Away_Team = "Hessle" AND Away_Score < 18;

Your question didn't make much sense but hopefully that works

Ari Misha
Ari Misha
19,286 Points

Hiya Rhys! You've SQL Error in there. Try "=" operator instead of "IN" clause. (:

Rhys Kearns
Rhys Kearns
4,976 Points

Haha you must of been quick! I editted it about 15 seconds after :D Thanks for noticing it though!

Ari Misha
Ari Misha
19,286 Points

Hiya Rhys Kearns! Im glad you were able to solve it on your own. (:

Mia Lee
Mia Lee
572 Points

Thank you Rhys Kearns and Ari Misha!