Nazdarek. Mam urobenu tabulku
user_friends ktora obsahuje tieto stlpce:
Id_pridal, pridal, id_priatetel, priatel, stav, datum.
No a potreboval by som urobit vyber dat z dalsich 3 tabuliek ale tak, aby mi vyberalo len data tykajuce sa "mojich priatelov" ulozenych v tabulke
user_friends. Urobil som si takyto multi select za pouzitia UNION ALL:
Kód:
$vytiahni=mysql_query("SELECT num_alb FROM user_gallery g WHERE status='public' AND EXISTS (SELECT id_pr FROM user_friends fr WHERE (g.id_autor = fr.id_pridal AND fr.id_priatel='$uzivatelID' AND fr.stav='friend') OR (g.id_autor = fr.id_priatel AND fr.id_pridal='$uzivatelID' AND fr.stav='friend'))
UNION ALL
SELECT id_act FROM user_activity1 a WHERE status='public' AND EXISTS (SELECT id_pr FROM user_friends fr WHERE (a.id_pridal = fr.id_pridal AND fr.id_priatel='$uzivatelID' AND fr.stav='friend') OR (a.id_pridal = fr.id_priatel AND fr.id_pridal='$uzivatelID' AND fr.stav='friend'))
UNION ALL
SELECT id_post FROM club_post p WHERE status='public' AND EXISTS (SELECT id_pr FROM user_friends fr WHERE (p.id_uzivatel = fr.id_pridal AND fr.id_priatel='$uzivatelID' AND fr.stav='friend') OR (p.id_uzivatel = fr.id_priatel AND fr.id_pridal='$uzivatelID' AND fr.stav='friend')) ");
kde
$uzivatelID je moje prihlasovacie id. Tento select funguje, no problem je v dlzke nacitavania dat z DB. Preto sa chcem opytat, ci by sa nejako nedal ten select upavit, aby sa mi skratil cas nacitavania dat z DB. Alebo je to jedina moznost ako vybrat tie data z DB?
Dakujem.