Witam. Mam problem z napisaniem warunku, który pobiera informację z dwóch tabel.

  1. SELECT a.*, b.*, count(tcat) AS topics, count(tcat) AS posts
  2. FROM forum a INNER JOIN forum_tp b ON b.tfid = a.fid
  3. GROUP BY tfid
  4. ORDER BY a.ford, b.tdate ASC


Jak pobrać ilość topiców gdzie tcat = 0??

Znalazłem już odpowiedź.
  1. SELECT a.*, b.*, count(DISTINCT IF(tcat=0, tid, NULL)) AS topics, count(DISTINCT IF(tcat>0, tid, NULL)) AS posts FROM forum a
  2. INNER JOIN forum_tp b ON b.tfid = a.fid
  3. GROUP BY tfid
  4. ORDER BY a.ford, b.tdate ASC


Mam tylko nadzieję że to wszystko będzie działać smile.gif