TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ekrem Tapan
NA
967
81.7k
Sql Query Problem
Jan 25 2016 11:51 PM
hello everyone
when i use this sql query getting error
All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
Select DT.* FROM (
Select NLID as MSID,M.SiteID,M.MenuID,Title,SKeywords from NewsLetter M
inner join STags STG on NLID=MainSid And M.SiteID = STG.SiteID and M.MenuID=STG.MenuID
where IsApproved='A' and DisplayStatus='U' And GETDATE() >= DisplaySDate And ((GETDATE() < DateAdd("D", 1, DisplayEDate)) Or (DisplayEDate Is null))
union
Select MGID as MSID,M.SiteID,M.MenuID,Case when M.Title<>'' Then M.Title else SM.Title end Title, SKeywords,
Case when M.MenuID='1' Then 'XX'
when M.MenuID='2' Then 'YYY'
when M.MenuID='3' Then 'ZZ'
end URL
From Messagess M
inner join STags STG on MGID=MainSid And M.SiteID = STG.SiteID and M.MenuID=STG.MenuID
inner join SiteMenu AS SM on STG.SiteID = SM.SiteID and STG.MenuID=SM.MenuID
where IsApproved='A' and DisplayStatus='U' And GETDATE() >= DisplaySDate And ((GETDATE() < DateAdd("D", 1, DisplayEDate)) Or (DisplayEDate Is null))
)AS DT inner join SiteMenu on DT.SiteID=SiteMenu.SiteID and DT.MenuID=SiteMenu.MenuID where IsDelete=0
problem on a red line when i cropped it its working normally but i need to use this line so how can i resolve this query ??
thanks
Reply
Answers (
1
)
More than one select query sql server 2008
Can We Join three tables SQL