Hab jetzt schon alles mögliche ausprobiert, aber krieg das einfach nicht hin.
In der Hoffnung, dass mir jemand helfen kann, poste ich hier mal die DB-Struktur:
CREATE TABLE al_comments (
id int(10) unsigned NOT NULL auto_increment,
type tinytext NOT NULL,
parent_id int(10) unsigned NOT NULL default '0',
author mediumint(8) unsigned NOT NULL default '0',
comment text NOT NULL,
timestamp bigint(20) NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
) TYPE=MyISAM;
CREATE TABLE al_news (
id smallint(5) unsigned NOT NULL auto_increment,
author_id tinyint(4) NOT NULL default '0',
headline tinytext NOT NULL,
content text NOT NULL,
timestamp bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
) TYPE=MyISAM;
CREATE TABLE al_users (
id mediumint(8) unsigned NOT NULL auto_increment,
level tinyint(3) unsigned NOT NULL default '254',
username tinytext NOT NULL,
password text NOT NULL,
email tinytext NOT NULL,
skin tinyint(3) unsigned NOT NULL default '0',
lastvisit bigint(20) unsigned NOT NULL default '0',
verylastvisit bigint(20) unsigned NOT NULL default '0',
newsletter tinyint(3) unsigned NOT NULL default '0',
voted text NOT NULL,
lastadd bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (id),
UNIQUE KEY id (id),
KEY id_2 (id)
) TYPE=MyISAM;
Und jetzt das was ich will:
-Die News sollen abgerufen werden.
-In der News ist eine Spalte author_id, die wird verknüpft mit al_users -> ich will, dass statt author_id der Name aus al_users (username) angezeigt wird.
-Als letztes stehen in al_comments noch alle Kommentare die zu dieser News geschrieben wurde. Jeder Kommentar wird per parent_id einer News zugeordnet. Nun will ich die Gesamt-Anzahl an Kommentaren zu einer bestimmten News noch angezeigt bekommen.
Also im Endeffekt brauch ich folgende Spalten:
-Alle aus al_news (auch die ID)
-Username (und zur Verknüpfung id) aus al_users
-COUNT() bzw. die Anzahl der Reihen mit der gleichen parent_id, passend zur news-ID.
Ich hoffe das war verständlich.
Vielen Dank für Eure Hilfe im Voraus! Auch für Deine bisherige Cheetah!