mysql - Insert Data from Table A to Table B WHERE (conditions) & SET Col.a = "xxx" -
| table [a] | table [b] ---------------------- --------------------- | | | id value data | id value data | ab 15 100 | ac 19 200 | ab 18 101 | ac 28 310 | ab 22 199 | ac 39 401
table old database table history data. table b current database table corrected value in id
i'll insert historic data table table b value<=xxxx , value >=xxxx , @ same time set data tablea.id = ac when inserted table b data outcome be.
| table [a] | table [b] -------------------- ---------------------- | | | id value data | id value data | ab 15 100 | ac 19 200 | ab 18 101 | ac 28 310 | ab 22 199 | ac 39 401 | | ac 15 100 | | ac 18 101 | | ac 22 199
i'll using insert ignore table has 3 column it's composite primary key. table description sample. table has alot more columns highlighting main difference data import want accomplish.
is want?
insert tableb (id, value, data) select 'ac', value, data tablea id = 'ab';
this inserts values , changes id
'ab'
'ac'
.
Comments
Post a Comment