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

Arun Kumar
Arun Kumar
3,750 Points

Whats wrong in my query??

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"

my query is :- SELECT * FROM users WHERE last_name = "Hinkley" OR "Pettit";

can someone help with what's the mistake in my query?

2 Answers

Steven Parker
Steven Parker
231,140 Points

:point_right: You can only combine complete comparisons.

So instead of this:

... last_name = "Hinkley" OR "Pettit"

You'd need something more like this:

... last_name = "Hinkley" OR last_name = "Pettit"

And another way to do it, but this may use a feature that hasn't been introduced yet, would be like this:

... last_name IN ("Hinkley", "Pettit")

For any future questions please include a link the the course page you are working with.

Arun Kumar
Arun Kumar
3,750 Points

Thanks for the help !:)

I forgot to add last_name for the other conditional. Thanks

SELECT * from users WHERE last_name = "Hinkley" OR last_name = "Pettit"

Steven Parker
Steven Parker
231,140 Points

:warning: FYI: According to a moderator, explicit answers without any explanation are strongly discouraged by Treehouse.