Combine a "Select" insert for some rows and "Values" insert for other rows in same query - mysql -
i've looked answer can't seem find covers it.
possible combine these 2 queries (which work individually) single query?
qry 1) inserts $id (as variable) , name pulled tableb, (which corresponds id) tablea. creates single row in tablea.
insert `tablea`(`id`,`name`) select $id, name `tableb` `id`='$id';
qry 2) inserts $id (as variable) , name (as text) tablea. creates single row in tablea.
insert `tablea`(`id`,`name`) values ('$id','changeme!');
use column name in select statement instead of $id
insert tablea(id,name) select tableb.id, tableb.name tableb tableb.id='$id' union select $id id,'changeme!' name;
using union
combine records.
Comments
Post a Comment