Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi, I have a Categories Table and an Article Table. Categories Table Schema: CategoryIDCategoryName Articles Table Schema: ArticleIDArticleNameDescriptionCategoryIDNow I want to select so I can show my records like this: CategoryName1All Articles in this Category1CategoryName2All Articles in this Category2 I think you get the idea: Here is my query but Its returning CategoryName many number of times because There are more articles than category. SELECT c.Title,a.Title,a.ArticleID FROM Articles a,Categories c WHERE c.CategoryID = a.CategoryID AND Active = 1 GROUP BY c.Title,a.Title,a.ArticleID Thanks,Mohammad Azam www.azamsharp.net
timmy
Master Smack Fu Yak Hacker
1242 Posts
Posted - 2005-07-24 : 19:36:40
It is possible to do, but surely it's easier to do this in the display layer?
SELECT C.DisplayName FROM (SELECT CategoryID, 0 as Seq, CategoryName as DisplayNameFROM Categories INNER JOIN Articles ON A.CategoryID = C.CategoryIDUNION SELECT CategoryID, 1 as Seq, ArticleName as DisplayNameFROM Articles) CORDER BY CategoryID, seq