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 trialArun Kumar
3,750 PointsWhats 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
231,248 PointsYou 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.
Damion Samuels
7,624 PointsSELECT * from users WHERE last_name = "Hinkley" OR last_name = "Pettit"
Steven Parker
231,248 PointsFYI: According to a moderator, explicit answers without any explanation are strongly discouraged by Treehouse.
Arun Kumar
3,750 PointsArun Kumar
3,750 PointsThanks for the help !:)
Michael Wallace
8,565 PointsMichael Wallace
8,565 PointsI forgot to add last_name for the other conditional. Thanks