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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -