Reputation: 2440
I have a database that consists of two tables, which look like this:
users
userID (PK) | email | password |
photos
photoID (PK) | userID (FK) | directory|
I want to insert a directory path into directory where the userID in users is say 1.
I was checking out SQL on the w3schools but I didn't know what this type of query is called.
Can anyone suggest the SQL I need to accomplish this query?
Upvotes: 0
Views: 63
Reputation: 4042
INSERT INTO photos (userID, directory) VALUES("1", "<your directory>");
or if you actually want to change the directory
UPDATE photos SET directory = "<your directory>" WHERE userId = "1";
Upvotes: 3
Reputation: 2081
Try something along these lines:
INSERT INTO photos SELECT 0, userID, 'directory_path' FROM users WHERE userID = 1
Upvotes: -1