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

Laura Sievert
Laura Sievert
349 Points

Can you check this line? I think it's right and the challenge isn't letting me move on!

SQL question-- I think my answer is right!

The question says Find all users with either the last name Hinkley or Pettit and my code is

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

and the hint that pops up says "Bummer! Did you select from the 'users' the last name? ... I think I did do that!

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

MOD NOTE: Changed topic of question from "General Discussion" to "Databases."

1 Answer

Jeff Lemay
Jeff Lemay
14,268 Points

To check multiple values for a single column, you can go one of two routes:

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

SELECT * FROM users WHERE last_name IN ("Hinkley", "Pettit");
Laura Sievert
Laura Sievert
349 Points

Right. That's what I wrote in this one (your first example)... I think the question is flawed. It keeps asking if I queried the right table and the right column, and those two are correct. Is there a way to report a bad question? I know they just added this SQL course recently- maybe it's a bug!

Jeff Lemay
Jeff Lemay
14,268 Points

You need to say last_name= twice. "Pettit" is not being checked against anything.

Laura Sievert
Laura Sievert
349 Points

Ah crap. Never mind. I didn't realize you had to write last_name in there twice. Thanks Jeff!

Jeff Lemay
Jeff Lemay
14,268 Points

No problem. Enjoy the journey!