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 trialAry de Oliveira
28,298 PointsSQL DATABASES
SQL DATA
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 CODE:
SELECT * FROM users WHERE last_name = "Hinkley" or "Pettit";
error.: Did you select from the users
table and test the last_name
column?
4 Answers
Sergey Podgornyy
20,660 PointsSELECT * FROM users WHERE last_name = "Hinkley" or last_name ="Pettit";
miikis
44,957 PointsYou kinda got it Ary — it's like this:
SELECT * FROM users WHERE last_name = "Hinkley" OR last_name = "Pettit"
A X
12,842 PointsWhy wouldn't it be acceptable to do:
SELECT * FROM users WHERE last_name = "Hinkley" OR "Pettit";
I mean I get that this throws up an error, but I don't understand why....is it just that SQL can't understand the association of these 2?
Don Ricardo JR
9,000 PointsI would think it would work that way as well, but I suppose one must be more explicit.
Jamal Shiekh
6,440 PointsSELECT * FROM users WHERE last_name = "Hinkley" or last_name ="Pettit";
chase singhofen
3,811 Pointschase singhofen
3,811 PointsIts too bad that we have to put last_name is twice. seems kinda redundant, you would think that would be sufficient enough. just like how we put commas after one another ex. last_name, first_name, id, score, etc...