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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Matt Caminiti](https://secure.gravatar.com/avatar/a14fdc2737957d6e7d599162a7d38a79?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Matt Caminiti
3,466 PointsOnly showing first result from "WHERE" clause.
Hi, i'm trying to query some data from my built database and for some reason i'm only able to retrieve what is outlined first in the where clause.
EX - SELECT Name, team, PPG FROM player_stats WHERE team = "ATL" OR "BOS" OR "DEN";
I'm able to see all information requested, but only for players from "ATL" or Atlanta. Is there any reason as to why this is happening? Same thing happens when attempting to join tables as well.
Any info would be greatly appreciated. Thank you!
2 Answers
![Vittorio Somaschini](https://uploads.teamtreehouse.com/production/profile-photos/740312/micro_Schermata_2014-03-27_alle_14.37.50.png)
Vittorio Somaschini
33,371 PointsHi Matt,
Have you tried?
SELECT Name, team, PPG FROM player_stats WHERE team = "ATL" OR team = "BOS" OR team = "DEN";
OR (probably better):
SELECT Name, team, PPG FROM player_stats WHERE team in ("ATL" "BOS" "DEN");
Let me know
Vitto
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsYou can only combine complete expressions.
So for example, you can't write
team = "ATL" OR "BOS" OR "DEN"
but you could write
team = "ATL" OR team = "BOS" OR team = "DEN"
.
But in this case, you might want to take advantage of a different kind of expression that uses multiple terms. Has the course covered the use of "IN
" yet?
Steven Parker
230,688 PointsSteven Parker
230,688 PointsI was thinking Matt might like to try solving this for himself using a few hints instead of getting a complete answer.
Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.![:fishing_pole_and_fish: :fishing_pole_and_fish:](https://image-proxy-cdn.teamtreehouse.com/7906c0fa55d1320e4b901e4ba573498c680db256/68747470733a2f2f7374617469632e7465616d74726565686f7573652e636f6d2f696d616765732f656d6f6a692f756e69636f64652f31663361332e706e67)
― Maimonides
Vittorio Somaschini
33,371 PointsVittorio Somaschini
33,371 PointsHi Steven.
Right, but he was so close ...
;)
Matt Caminiti
3,466 PointsMatt Caminiti
3,466 PointsThanks guys, the mysql syntax is just a little different than what i'm used to. "IN" expression has been covered too! Thank you!