Selecting primary keys that do not have foreign keys in another table
问题 For simplification, I have two tables related with one to many using a foreign key, for example: Users table: id name Actions table: id user_id one user may have many actions or not. I need an sql select that returns users ids that don't have a user_id value in the actions table. Users Table: id name 1 John 2 Smith 3 Alice Actions Table: id user_id 1 3 2 1 So I need an sql query that returns the user id 2 (Smith) because the foreign key values don't include the id 2 I tried the following SQL,