Yes, why not, you can use same query for different MySql Database, all you need is their authentication to access that particular database. I mean to say, the username
and password
for each database. Like in php
we use these script to connect our database.
<?php
$hostname = 'localhost'; //server
$dbname = 'myphp'; //database
$username = 'root'; //username
$password = ''; //password
mysql_connect($hostname, $username, $password) or DIE('Connection to host is failed, perhaps the service is down!');
mysql_select_db($dbname) or DIE('Database name is not available!');
?>
So, you need to create different connection script and change them accordingly. As you see,in my connection script hostname
is the server location (generally it is an IP address, where your server is), currently it is set to localhost
(you can change it to 127.0.0.1), since my computer itself serve as a server. So, you need to change the server details only (if database, username and password are same for all).
Now, coming to next part of your question i.e. speed issue, so i would say, it depends on the server, how much time it takes to respond. There are many factors (like number of user, server respond time and etc) that affects the speed issue.