I have two tables:
users (id, email)
devices (id,name, userid)
I want to insert a new device on insert ther userid based on the email in the users table:
INSERT INTO devices (name, userid) VALUES ('devicename', retrievedUserId)
How can I pass the id from the users table to above query?
SELECT id from users WHERE email = '[email protected]'
I would like something like this:
INSERT INTO devices (name, userid) VALUES ('devicename', SELECT id from users WHERE email = '[email protected]')
But with correct syntax :) It has been a while since I wrote vanilla SQL