Originally posted by bogu
SELECT u.user_id,u. nic,u. lastlogin,count(g.guestbook.id) AS guestposts,count(f.forum_posts.id) AS forumposts FROM user u
LEFT JOIN guestbook g USING (user_id)
LEFT JOIN forum_posts f USING (user_id)
WHERE u.user_id=$UserId GROUP BY u.user_id
[/B]
my try is
SELECT u.user_id, u.nic, u.lastlogin,
count(g.angst_guestbook.id) AS guestposts,
count(f.angst_forum_posts.posttime) AS forumposts FROM angst_user u
LEFT JOIN angst_guestbook g USING (user_id)
LEFT JOIN angst_forum_posts f USING (user_id)
GROUP BY u.user_id
and the following error-message is:
Unknown table 'g.angst_guestbook' in field list
but i dont know why...
the table angst_guestbook is there...
shortend Table structure:
CREATE TABLE angst_guestbook (
id int(11) NOT NULL auto_increment,
user_id int(11) NOT NULL default '0',
posttime timestamp(14) NOT NULL,
message text NOT NULL,
visitor mediumint(9) NOT NULL default '0',
PRIMARY KEY (id),
) TYPE=MyISAM;
CREATE TABLE angst_forum_posts (
user_id mediumint(9) unsigned NOT NULL default '0',
posttime timestamp(14) NOT NULL,
message text NOT NULL,
PRIMARY KEY (post_id),
) TYPE=MyISAM;
CREATE TABLE angst_user (
user_id int(9) unsigned NOT NULL auto_increment,
nic varchar(22) NOT NULL default '',
reg_mail text NOT NULL,
register date NOT NULL default '0000-00-00',
lastlogin timestamp(12) NOT NULL,
PRIMARY KEY (user_id),
) TYPE=MyISAM PACK_KEYS=1 CHECKSUM=1;