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.
| 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 11The structure of my table(tblNews) is:ID int 4 0Publish bit 1 0PublishDate datetime 8 0[Language] bit 1 0TypeId int 4 1Province varchar 25 0Title varchar 250 0Header varchar 750 1Author varchar 250 0Body ntext 16 0Hits int 4 0UserID int 4 1[Order] int 4 0and for News_TypesTypeID int 4 0Name varchar 100 0Description varchar 250 1I seriously don't know what to doThanks to helpPascal |
|
|
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 exampleThanks to answerPascal |
 |
|
|
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.. |
 |
|
|
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 exampleThanks to answerPascal |
 |
|
|
|
|
|
|
|