2 tabelki mysql (news, comments) utworzone w ten sposób:
CREATE TABLE news ( id int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, topic varchar(250) NOT NULL, contents text NOT NULL, autoformat tinyint NOT NULL, datetime char(16) NOT NULL ); CREATE TABLE comments ( id int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, username char(50) NOT NULL, mail char(50), type tinyint UNSIGNED NOT NULL, contents text NOT NULL, datetime char(16) NOT NULL );
I teraz chcę jednym zapytaniem pobrać newsy wraz z ilością komentarzy dla każdego. Kombinuję w ten sposób:
SELECT COUNT(comments.id),news.id,news.contents,news.topic,news.datetime,news.autoformat FROM news,comments GROUP BY news.id ORDER BY id DESC
Ale nie działa :/
Proszę o pomoc
