Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Showing top n most read articles, using three tables

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-08-19 : 19:12:33
Blake writes "I have three tables which I'll simplify as:

create table users (
user_id integer identity primary key,
name varchar(100) not null
);

create table articles (
article_id integer identity primary key,
author integer references users(user_id),
title varchar(255) not null,
body text
);

create table articles_viewed (
article_id integer references articles,
user_id integer references users,
date_viewed datetime not null,
unique (article_id, user_id)
);

What I want to do is to use all three tables to display the top n most read articles, showing the ranking, the title, the author, number of views, and an excerpt from the body of the article (eg: first 200 characters or so). I would like to have this returned in a single recordset instead of having to first rank the articles as a recordset, then iterate through the article_id values to query the rest of the infor
   

- Advertisement -