How to create one update query (mysql) on multiple databases
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
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;
Check more discussion of this question.
Related posts:
- Best Mysql DB Engine When Insert update delete query is not made
- Are there any pitfalls with having multiple MySQL databases on 1 server node?
- How can artificially create a slow query in mysql?
- Multiple databases on Mysql crashes the mysql server often
- Create a SharePoint Survey from an Excel spreadsheet
Leave a comment
Recent Posts
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





