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 trialEthan Martin
Courses Plus Student 1,883 PointsWho are these Actors?
Hey guys! I can't tell what I'm doing wrong for this part of the code. Can someone check this? Thank you!
SELECT name FROM actors WHERE "id (PK)" IN (12127, 6901, 2071, 2831);
4 Answers
KRIS NIKOLAISEN
54,972 Points(PK) just identifies id as the primary key and is not part of the column name. Try:
SELECT name FROM actors WHERE id IN (12127, 6901, 2071, 2831);
KRIS NIKOLAISEN
54,972 PointsA primary key is a unique identifier for records in a table and is used for CRUD (creating, reading, updating, deleting records ) and for creating relationships with other tables. The most commonly used is an auto-incrementing integer (1,2,3,4,...).
Ethan Martin
Courses Plus Student 1,883 PointsThank you! But what does primary Key mean?
Stephanie Youstra
18,513 PointsEthan Martin ~ a primary key is a unique identifier for that row in that table, a number assigned only to that particular row.
So, for this question you're referring to, Christian Bale has the unique identifier of 2071. He is the only individual in that Actors table with an ID of 2071, so anything in the Actors table that is associated with ID 2071 is going to be related to Christian Bale. Since the primary keys usually begin with 1
and auto-increment (increases by 1 each time), Christian Bale most likely (but not necessarily) was the 2071st actor added to this database.
It's the primary key because it's the primary way of identifying that particular row of data.
Ethan Martin
Courses Plus Student 1,883 PointsEthan Martin
Courses Plus Student 1,883 PointsSorry wrong location... Thank you for your help!
but what does primary key mean? Why does it only have that for one column?