Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zapytanie zliczające ilość komentarzy w newsie
tommy4
post
Post #1





Grupa: Zarejestrowani
Postów: 288
Pomógł: 12
Dołączył: 2.12.2005

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


  1. SELECT n.title AS ntitle, n.content AS ncontent, n.id AS nid, n.source AS nsource, n.time AS ntime, n.image AS nimage, u.id AS uid, u.name AS uname, u.surname AS usurname, COUNT(c.id) AS commentscount
  2. FROM news AS n, users AS u
  3. LEFT JOIN comments AS c ON (c.what='N' AND c.wid = n.id)
  4. WHERE u.id = n.user
  5. GROUP BY n.id
  6. ORDER BY n.time DESC


#1054 - Unknown column 'n.id' in 'on clause'

Kiedyś miałem już podobny problem: http://forum.php.pl/index.php?showtopic=63...rt=#entry336520 i nie wiem w końcu co robię źle. :C

EDIT:

ok, got it

  1. SELECT n.*, u.name AS uname, u.surname AS usurname, COUNT(c.id) AS commentscount
  2. FROM news AS n
  3. LEFT JOIN users AS u ON u.id = n.user
  4. LEFT JOIN comments AS c ON (c.what='N' AND c.wid = n.id)
  5. WHERE u.id = n.user AND n.nday = 1
  6. GROUP BY n.id ORDER BY n.time DESC


Ten post edytował tommy4 19.08.2007, 14:12:01
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: 21.08.2025 - 19:46