Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> rozwinięcie join
fiszol
post
Post #1





Grupa: Zarejestrowani
Postów: 453
Pomógł: 16
Dołączył: 25.05.2004
Skąd: Gorzów Wlkp.

Ostrzeżenie: (0%)
-----


Próbuję sobie skontruować zapytanie tak żeby za jednym razem wyciągnąć newsa razem z komentarzami, ich autorami i tak dalej
  1. <?
  2. $newsy = $db->get_results("SELECT news.*, comments.* , forum_users.username
  3. FROM news
  4. LEFT OUTER JOIN forum_users
  5. ON news.author_id = forum_users.id 
  6. LEFT OUTER JOIN comments
  7. ON comments.author_id = forum_users.id AND comments.item_id = news.id ".$str_cat.
  8. ORDER BY unixdate DESC ".$str_limit."");
  9. ?>

Ale w tej chwili wyciągam tylko komentarze których autorem jest autor newsa...

//gópie slasze :/

Ten post edytował fiszol 24.06.2007, 14:06:33
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
UDAT
post
Post #2





Grupa: Zarejestrowani
Postów: 442
Pomógł: 0
Dołączył: 27.12.2005

Ostrzeżenie: (0%)
-----


  1. SELECT news.*, comments.* , forum_users.username
  2. FROM news #Pobranie newsa
  3.  
  4. LEFT JOIN comments #Pobranie komentarzy do newsa
  5. ON comments.item_id = news.id ".$str_cat."
  6.  
  7. LEFT JOIN forum_users #Pobranie userów(autorów )
  8. ON comments.author_id = forum_users.id
  9.  
  10. ORDER BY unixdate
  11.  
  12. DESC .$str_limit
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 17.10.2025 - 20:42