I\'ve built a news site: - The articles are shown on the front page ordered by date. The newest one first. - The news are in the table \"news\" with the fields \"id\", \"t
The following is by no means exhaustive/definitive, but it should get you going in the right direction.
news
=====
id
title
text
tag
===
id
tag
tag_map
=======
tag_id
news_id
favorite_tags
=============
user_id
tag_id
SELECT *
FROM favorite_tags
JOIN tag_map ON favorite_tags.tag_id = tag_map.tag_id
JOIN news ON tag_map.news_id = news.id
WHERE favorite_tags.user_id = $userid
The query's performance (whether in your sub-select approach, or Frank Farmer's more elegant join-based one) will chiefly depend on indices. Just remember that MySQL uses just one index per table, and the proper set of indices (depending on the query you want to optimize) invariably becomes pretty obvious...