mysql - How to insert into a table from another table and from user input? -
what trying this
insert books(borrower_name,isbn) values("jane",select isbn table...);
this wrong obviously. trying work way (if did).
you very close
insert books (borrower_name, isbn) select 'jane', isbn table_name -- id = ?
you might want limit number of rows coming table_name
using where
clause , proper condition(s)
here sqlfiddle demo
more on if meant return select
only scalar value (just 1 isbn) correct in first place , could've used syntax showed in question
insert books (borrower_name,isbn) values ('jane', ( select isbn table_name id = 1 ));
here sqlfiddle demo
Comments
Post a Comment