Home  >  Q&A  >  body text

Updates to multiple databases - mysql

<p>I am new to mysql. I have a list of 10 databases containing the same table structure. The same table needs to be updated for each database. Is there an option to do it through phpmyadmin without selecting each database? </p> <p>Or is there a function similar to: <code>USE LIKE gc%</code>? </p>
P粉129731808P粉129731808392 days ago405

reply all(1)I'll reply

  • P粉268654873

    P粉2686548732023-08-28 09:36:59

    If you need to update the original data, you can do the transaction like this. You can't escape the fact that you need to make 10 different queries.

    START TRANSACTION;
      UPDATE  `db_name1`.`table_01` SET `parameter`=`value` 
        WHERE `parameter`=`value`;
      UPDATE  `db_name2`.`table_01` SET `parameter`=`value` 
        WHERE `parameter`=`value`;
      UPDATE  `db_name3`.`table_01` SET `parameter`=`value` 
        WHERE `parameter`=`value`;
    COMMIT;

    reply
    0
  • Cancelreply