加入Query是不是有用吗?

编程入门 行业动态 更新时间:2024-10-12 16:25:04
本文介绍了加入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是不是有用吗?

本文发布于:2023-11-07 00:18:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565046.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:有用吗   Query

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!