Ho spostato alcune tabelle del mio database che hanno avuto problemi con il traffico verso un altro server e non voglio usare le tabelle federate per un sacco di motivi (le prestazioni sono la ragione principale). Quindi devo creare 2 connessioni diverse nella mia classe PHP e riscrivere le mie query nel codice che è entrato tra tabelle da server diversi.Mysql Query su server senza l'utilizzo della tabella federata
Ad esempio, ho due tabelle: Utenti ed Enterprise che si trovano in server diversi.
Quando era sullo stesso server, la query è stata:
select name from Enterprise E
inner join Users U on E.cod = U.cod
where E.cod = $my_code and U.codUsers in ($users);
Così ho cambiato a questo:
$rst= select group_concat(U.cod) from Users as U
where U.codUsers in ($users)
select name from Enterprise E
where E.cod = $mycode and E.cod in ($rst);
mia domanda è, come posso simillary fare questo quando ho questo tipo di query:
select e.name, e.datebegin, e.dateend from Enterprise E
leftjoin (select h.callQuantity, h.history from thirdtable
inner join Users u on e.cod = u.cod
where u.codHistory in (1,2,3)
group by u.cod)
La mia domanda è chiara? Ci scusiamo per il mio inglese
Ciao Shermano? A quale server appartiene "terzo classificato"? –
La query che si desidera refactor ha un problema con la sintassi: leftjoin => left join; thirdtable non ha un nome alias; e.cod non appartiene alla subquery; la tabella derivata non ha alias; a sinistra si unisce senza condizioni? –