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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -