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)
 Difficulty with a querry

Author  Topic 

pharvey
Starting Member

20 Posts

Posted - 2006-02-28 : 10:41:31
Hi guys!

I'm doing a news website. We have different type of news like sports, science, technology etc...

For some reasons I need to retrieve the first two row of certain type of news.
Example: I want to retrieve the first 2 row of those 2 TypeId ==> 6 and 11

The structure of my table(tblNews) is:
ID int 4 0
Publish bit 1 0
PublishDate datetime 8 0
[Language] bit 1 0
TypeId int 4 1
Province varchar 25 0
Title varchar 250 0
Header varchar 750 1
Author varchar 250 0
Body ntext 16 0
Hits int 4 0
UserID int 4 1
[Order] int 4 0

and for News_Types
TypeID int 4 0
Name varchar 100 0
Description varchar 250 1

I seriously don't know what to do

Thanks to help

Pascal

pharvey
Starting Member

20 Posts

Posted - 2006-02-28 : 11:10:40
Sorry my explanation was bad, I need to retrieve the first 2 row of each TypeId but we don't know how many TypeId will be sent.

The beginning of my querry will look like this:

CREATE PROCEDURE sp_News_GetSpecific
@Sections varchar(50)
AS
....


@Sections is all the TypeId I will have to retrieve the first 2 row.
@Section might be 4,11 or 6,12 or 4,6,11,12 etc...

Somewhere in your querry you will need a TypeId IN (4,11,12) by example

Thanks to answer

Pascal
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-02-28 : 11:10:46
Do you have some sample data..

Without it I would suggest you SELECT TOP 2 and use an ORDER BY, but can't say for certain whether that would work..
Go to Top of Page

pharvey
Starting Member

20 Posts

Posted - 2006-02-28 : 11:11:55
Sorry my explanation was bad, I need to retrieve the first 2 row of each TypeId but we don't know how many TypeId will be sent.

The beginning of my querry will look like this:

CREATE PROCEDURE sp_News_GetSpecific
@Sections varchar(50)
AS
....


@Sections is all the TypeId I will have to retrieve the first 2 row.
@Section might be 4,11 or 6,12 or 4,6,11,12 etc...

Somewhere in your querry you will need a TypeId IN (4,11,12) by example

Thanks to answer

Pascal
Go to Top of Page
   

- Advertisement -