Jump to content

how to ORDER BY sql separate severs


ala888

Recommended Posts

I have 10 serversuploads from users are passed in round robin fashion to each sql server.

 

There is a main page where the top 20 "liked" content is displayed.How do I go about selecting the top 20 liked results but from 10 different

servers.

 

Im really stumped here.

Is it even possible to do an "ORDER BY"-like statement with the returned mysqli_result objects in php?

Link to comment
Share on other sites

i have 10 servers. on different hosts and different ip addresses. and I need a way to do an ORDER BY `column_name` by the differing mysqli_result objects returned from each server

 

10 sql queries from diff servers => make into a temp table => order by => get 20 results

Edited by ala888
Link to comment
Share on other sites

I've never encountered that situation. I'll monitor this topic. It's a very interesting question.

Link to comment
Share on other sites

Glad to hear that jsg (though probably not the answer the OP was hoping for) . I couldn't imagine how to do that.

Edited by niche
Link to comment
Share on other sites

One way could be to have a single database which has a cron job running on its server that pulls in all the data and stores it, so then the application only has to look in one place.

Link to comment
Share on other sites

One way could be to have a single database which has a cron job running on its server that pulls in all the data and stores it, so then the application only has to look in one place.

mind giving me like a really simple example of that? how would that go ?sql = "select ..."mysqli_result = mysqli_query($client,$sql);

INSERT INTO (_) values (mysqli_result) ?

 

or do I have to loop through the entire result set?

 

edit: can I insert mysqli_result queries or do I have to do conventional rows

Edited by ala888
Link to comment
Share on other sites

my suggestion was an architectural one, it's not just use query xzy. You will need to plot it all out, write out the psuedo steps if you need, and then approach one piece at a time. First is the script that can connect to all your databases, gets the results from each one, then inserts into the master database. Getting it to run on a cron would come after that.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...