Thanks a lot! One more thing though - how can I now get those articles which have no comment (and those WITH comments, of course)? I tried using LEFT OUTER JOIN instead of the last WHERE token, but it seems to slow things down a lot! The costvalue from EXPLAIN without JOIN was 163 and now it is 4692; thats 30 times more...
-Andris Spruds > And what you (I assume) want to know is the number of comments for > each article together with a bunch of other things (author,...). > Try this : > SELECT ar.id, c.cmnts, ar.author author_id, ar.category > category_id, ar.updated, ar.title, ar.synopsis, > u.name || ' ' || u.surname author_name, u.email > author_email,u.username author_username > FROM ar_articles ar, users u, > (select count(id) as cmnts, article_id from ar_comments group by article_id ) c > WHERE usr.id=ar.author AND c.article_id = ar.id _______________________________________________ sapdb.general mailing list [EMAIL PROTECTED] http://listserv.sap.com/mailman/listinfo/sapdb.general
