Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have several DBS on the same mysql server. The DBS's structure and schema are exactly the same (only data is different)

the query on certain db works well like this (written in phpmyadmin)

UPDATE  `mdl_modules` SET `visible`=0 
WHERE `name` IN ("survey","feedback","audio","testing")

I thought it could be something like that:

UPDATE `db_name1`.`mdl_modules`, `db_name2`.`mdl_modules`,`db_name3`.`mdl_modules`
SET `visible`=0  WHERE `name` 
IN ("survey","feedback","audio","testing")

but this doesn't work and I get an error of course I have more that 3 dbs..

Thanks

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Use transactions.

START TRANSACTION;
  UPDATE  `db_name1`.`mdl_modules` SET `visible`=0 
    WHERE `name` IN ("survey","feedback","audio","testing");
  UPDATE  `db_name2`.`mdl_modules` SET `visible`=0 
    WHERE `name` IN ("survey","feedback","audio","testing");
  UPDATE  `db_name3`.`mdl_modules` SET `visible`=0 
    WHERE `name` IN ("survey","feedback","audio","testing");
COMMIT;
share|improve this answer
    
Hey Thanks a lot That's exactly what I was looking for. it worked. Thank you! –  Miki A Mar 27 '12 at 8:56
    
Is there Any way to do it in One sentence? –  Miki A Mar 27 '12 at 9:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.