Answer the question
In order to leave comments, you need to log in
How to conduct an insert if one of the inserted values needs to be found using SELECT?
Hello.
There are 2 tables:
requests - id, file_id, the rest is not important.
files - id, name
I have table name file as input. How to build an insert request so that in the end I get the id of the file as the second parameter, and not its name?
Answer the question
In order to leave comments, you need to log in
insert into requests (file_id /*other*/) values((select id from tablename where name = ?) /*, other*/);
insert into requests (file_id /*other*/)
select id, /* other const values*/ from tablename where name = ?;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question