This should be pretty basic but i can't figure it out. Have a table 'values'
entity|attribute|value
frank - shirt - red
frank - hat - green
sam - shirt - blue
sam - hat - orange
how do i set all hats color's to be the same as the shirt color, of the same person to give frank a red hat and sam a blue hat.
i was looking for a solution to this and i came up on this post. however running the sql lead to a syntax error.
Refering to the mysql docs http://dev.mysql.com/doc/refman/5.0/en/update.html i noticed - at least in version 5 - mysql has a different syntax for this.
the general statement would be:
update table t1, table t2
set t1.field1 = t2.field2, ..., t1.fieldN = t2.fieldN
where t1.someid = t2.someid and t1.fieldX = '...' and t2.fieldY = '...'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With