Query for Multiple Databases

Discussion in 'Databases' started by deriklogov, Jul 18, 2009.

  1. #1
    Hey , I got around 60 databases, all of them have same structure (tabled, fields and etc). I need to run 1 query to process all of them at once , query looks like this

    DELETE FROM tb_ad WHERE `id_c`>'15' and `id_c`<'23'

    How I can run this query for all databases at once ? without switching databases
     
    deriklogov, Jul 18, 2009 IP
  2. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I'm not aware of a way to do it with a simple query, but it can be done with php if that's a route you're willing to take.
     
    Goramba, Jul 18, 2009 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    If your user has access to the other databases you can switch databases and run the same query.

    USE other_database_name;
    DELETE FROM tb_ad WHERE `id_c`>'15' and `id_c`<'23'

    You would need to figure out how to logically apply this to your needs, but as long as the user has access, it should work.
     
    jestep, Jul 20, 2009 IP
  4. DoDo Me

    DoDo Me Peon

    Messages:
    2,257
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    0
    #4
    as for as I know, you cannot. you have to process them one by one
     
    DoDo Me, Jul 25, 2009 IP
  5. TheOwl

    TheOwl Peon

    Messages:
    34
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Why not try to use inner join / left join statement?..
     
    TheOwl, Jul 27, 2009 IP
  6. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #6
    I don't think he's talking about tables, but completely independent databases.
     
    jestep, Jul 27, 2009 IP