database - How to copy 3 columns from one table into another in mysql -
i have 2 tables , both include 2 columns, sureness , kindness , and related each other dataitemid , id. show structure put 2 selects got database:
select id,sureness,kindness omid.tweet ; select id,dataitemid,sureness,kindness omid.entity_epoch_data ; and want copy value of sureness , kindness in omid.tweet entity_epoch_data entity_epoch_data.entityid equal entityid coming entity_relation tweet.id =entity_relation.id
i want in mysql rather reading whole table in java , updating database in loop confused. how can that?i appreciate help:)
update:
i wrote code follow not work:
update tweet, entity_epoch_data set entity_epoch_data.sureness= tweet.sureness, entity_epoch_data.kindness = tweet.kindness , entity_epoch_data.calmness = tweet.calmness , entity_epoch_data.happiness = tweet.happiness entity_epoch_data.entityid in( select entityid omid.entity_dataitem_relation inner join omid.tweet t on entity_dataitem_relation.dataitemid = t.id)
it's pretty straight forward. update clause works join , use set set values
update tweet inner join entity_epoch_data on tweet.id = entity_epoch_data.id set entity_epoch_data.sureness= tweet.sureness, entity_epoch_data.kindness = tweet.kindness
Comments
Post a Comment