skip to Main Content

I’m new with mysql.
I have a list of 10 databases with same table structure.
Need to update same table for each database.
Is there any option to do it through phpmyadmin without selecting each database?

or is any function that will be like: USE LIKE gc% ?

2

Answers


  1. If its raw data you need to update, make a transaction like this. You cant escape the fact you need 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;
    
    Login or Signup to reply.
  2. when you have multiples databases with same name this is one option.

    select DISTINCT concat('UPDATE ', TABLE_SCHEMA, '.content SET ')
    from INFORMATION_SCHEMA.`COLUMNS` c 
    where TABLE_NAME = "content" 
      and TABLE_SCHEMA LIKE "c_%";
    

    the names of schemas begin with "c_"

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search