When I execute this query:
SELECT * FROM (SELECT `db` FROM site WHERE `url`='$site') . smspq
I get this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘. smspq’ at line 1
This query works, though:
SELECT * FROM `database` . `table`
Why?
This is not the way SQL works. You have to state clearly what table in what database you like to work on.
You can set up the most liked db by
and every request to a table will be passed to that database.
The only way is to use Prepare and Execute (have a look at the docs), but with plain commands (SELECT, UPDATE,…) you can’t reach your desired goal that way
UPDATE
You have to split the Query:
First Query
Second:
(because of the $ i think it will be called from php ;o) )