MySQL Forums
Forum List  »  Performance

Rewrite Subquery for MySQL 4.0, maintaining performance.
Posted by: Dave Adams
Date: October 01, 2005 05:34AM

How can i rewrite this subquery to a series of joins for mysql4,

i've tried but cant do it. Take into account that it needs to be just a good with performance.

SELECT feeds.id, feeds.title, feeds.url,
(SELECT COUNT(item_id) FROM feeds_items
WHERE feeds_items.item_id NOT IN (SELECT item FROM users_items_read WHERE user = users_to_feeds.user AND feed = feeds.id) AND feeds_items.feed_id = feeds.id
GROUP BY feed_id) AS 'unread'
FROM users_to_feeds
INNER JOIN feeds ON feeds.id = users_to_feeds.feed
WHERE users_to_feeds.user = '$this->user_id'
GROUP BY feeds.id ORDER BY feeds.title ASC

Cheers for any help,

Options: ReplyQuote


Subject
Views
Written By
Posted
Rewrite Subquery for MySQL 4.0, maintaining performance.
1877
October 01, 2005 05:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.