Categories
How to update all profile fields in one request if those fields are rows and not columns?
There are tables: users [UserId][UserName] userprofiles [UserId][Field][Value] That is, the fields in this MySQL allows you to execute a query
Answer the question
In order to leave comments, you need to log in
Loop through all rows and update each
If (`UserId`, `Field`) is a unique key, then
INSERT INTO `userprofiles` (`Field`, `Value`) VALUES ('fld1', 'val1'), ('fld2', 'val2'), ... ('fldN', 'valN') ON DUPLICATE KEY UPDATE `Value` = VALUES(`Value`) WHERE `UserId` = 'uid'
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question