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 |
DvlprWun
Starting Member
2 Posts |
Posted - 2012-12-10 : 01:03:07
|
I'm not as good as I used to be with T-SQL seeing as to how I mainly do Front End nowadays, but I'm trying to get back into SQL and the other parts of the N-tier. I'm making my first attempt at writing an Orchard CMS module and came up with this. It works, but I'm sure it's not the most efficient way to do it. Can someone help me out here?select top(1)oBody.ContentItemRecord_id, oBody.Text, oRoute.Titlefrom oCMS__Common_BodyPartRecord as oBody, oCMS__Routable_RoutePartRecord as oRoutewhere oBody.ContentItemRecord_idin (Select top(1) Id from oCMS__Common_CommonPartRecord where Container_id is not null order by ModifiedUtc desc)AND oRoute.ContentItemRecord_id in (Select top(1) Id from oCMS__Common_CommonPartRecord where Container_id is not null order by ModifiedUtc desc) order by oBody.Text descThanks for reading!Killer Coding Ninja Monkeys do Exist... |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2012-12-10 : 01:23:48
|
select top(1)oBody.ContentItemRecord_id, oBody.Text, oRoute.Titlefrom oCMS__Common_BodyPartRecord as oBody JOIN oCMS__Routable_RoutePartRecord as oRoute ON oBody.ContentItemRecord_id = oRoute.ContentItemRecord_idwhere oBody.ContentItemRecord_id= (Select top(1) Id from oCMS__Common_CommonPartRecord where Container_id is not null order by ModifiedUtc desc)ORDER BY oBody.text DESC--Chandu |
|
|
DvlprWun
Starting Member
2 Posts |
Posted - 2012-12-10 : 01:45:15
|
Thanks! That returns the same results.With that being said, I'm guessing that this is also the most efficient way to do this query:select idTbl.TagsPartRecord_Id, idTbl.TagRecord_Id, Tags.TagName from oCMS__Orchard_Tags_ContentTagRecord as idTbl join oCMS__Orchard_Tags_TagRecord as Tags on idTbl.TagRecord_Id = Tags.Idwhere idTbl.TagsPartRecord_Id = 701order by idTbl.id descKiller Coding Ninja Monkeys do Exist... |
|
|
|
|
|