本文介绍了加入Query是不是有用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
ALTER Procedure [dbo].[GetMoviesForDelete] As Begin select distinct(mt.MovieID),m.MovieName+' ('+m.Language+')' as MoviesWithLanguage from Movies m inner join MovieTimings mt on m.MovieID=mt.MovieID and -- m.Status != 'Closed' and m.Active = 1 and mt.Active =1 and m.Active=1 and convert(varchar,m.ReleaseDate,112)<convert(varchar,getdate(),112)> and m.MovieID not in (select distinct(MovieID) from MovieTimings where convert(varchar,Date,112) >= convert(varchar,getdate(),112)) End
推荐答案
看起来您已将所有WHERE子句条件附加到JOIN。纠正它。 你没有从表MovieTimings中得到任何东西。如果是这样你就不需要加入。如下所示的直接查询可以: Looks like you have given all your WHERE clause conditions appended to JOIN. Correct it. You are not getting anything from table MovieTimings. You don''t need a join if so. A direct query like below would do: select distinct(mt.MovieID),m.MovieName+' ('+m.Language+')' as MoviesWithLanguage from Movies m WHERE m.Active = 1
如果你想从MovieTimings表中设置一些东西, 尝试:
In case you want to set something from MovieTimings table too, Try:
ALTER Procedure [dbo].[GetMoviesForDelete] As Begin select distinct(mt.MovieID),m.MovieName+' ('+m.Language+')' as MoviesWithLanguage, mt.* from Movies m inner join MovieTimings mt on m.MovieID=mt.MovieID and WHERE m.Active = 1 and m.MovieID not in (select distinct(MovieID) from MovieTimings) End*删除了与日期条件相关的where子句,因为不清楚是什么ex你试图在那里做什么,以及来自日期字段的地方。您可以根据需要在上面的简单查询中处理它。
*Removed where clause related to date condition as it was not clear what exactly you were trying to do there and where from the field ''Date'' came. You can handle it now as per your need post the simple query above.
更多推荐
加入Query是不是有用吗?
发布评论