M
M
Maxima2011-02-23 12:37:08
MySQL
Maxima, 2011-02-23 12:37:08

Combine multiple MySQL query results into one

There is a request from server A
$queryA = mysql_query("SELECT * FROM table");
and a request from server B
$queryB = mysql_query("SELECT * FROM table");
The tables are identical, except for the data.
Data from server A is partially (at the beginning) equal to data from server B
Sorted by date.

Need to fetch data from two tables into one mysql_fetch_array
Is this possible?

Answer the question

In order to leave comments, you need to log in

9 answer(s)
A
Anatoly, 2011-02-23
@Maxima

mysql_fetch_array needs a resource, you have two resources, in the end nothing will work for you, array_merge will help you, I think this is the only option. Though I could be wrong =)

A
Alexey Sidorov, 2011-02-23
@Gortauer87

Well… sadness. Urgent smoking normalization

@
@mgyk, 2011-02-23
_

There is a problem with setting the task. You can read data from another server using the FEDERATED engine. But you will be upset by the speed.
You can raise master-master replication in mysql. That is, each server will consider itself a slave :). In this case, it remains only to transfer ip in case of problems. The data will be pulled automatically.

B
BearOff, 2011-02-23
@BearOff

>> as a result, the data at the time of the reserve operation is written to it,
if I understand correctly, after the main server rises, you have unique data on the backup server, and hence the need to combine the results arises?
If this is the case, then your problem is not in combining two requests, but in the fact that after restoring the main server, the first thing you need to do is synchronize it with the backup one, and then work only with the main one.

T
TimTowdy, 2011-02-24
@TimTowdy

Don't be perverted. You are trying to emulate master-master replication using PHP.

H
homm, 2011-02-23
@homm

UNION

A
Atrax, 2011-02-23
@Atrax

What for? What do you want to guess?
There are two connections, the size of two "fetches" is approximately equal to the size of a "double".
Yes, and it's impossible. As far as I know, it's basically impossible.

E
equand, 2011-02-23
@equand

Collect in storage in one array differently in any way.

E
eternals, 2011-02-23
@eternals

1. Nothing, yeptid. This is not Microsoft SQL Server with its SSIS. Suck a skittle, in general.
Or get out with the federated die.
2. About backup, replication, etc. (there was an extension in the comments). mysql has a built-in replication mechanism and it will most likely suit you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question