我确定我肯定在这里犯了一个小错误,但是我一直在寻找有关此问题的帮助,而我所能找到的只是关于条件内联接的信息。问题是此存储过程根本不返回任何内容。如果我只输入:SELECT TOP (6) UserID, Category, Title, SUBSTRING(Article, 0, 200) AS Summary, DatePostedFROM ContribContentWHERE (DateFeatured IS NOT NULL)ORDER BY DateFeatured DESC进入控制台,然后返回值。因此,这一定与内部联接有关吗? 这个想法是:拿走已经精选(DateFeatured不是NULL)并将它们全部放入临时表从用户表中获取用户名和图片,并使用UserID值将它们与临时表中的值进行匹配。按照每个帖子的精选日期排序临时表。从表中选择前六个条目这是代码:ALTER PROCEDURE [dbo].[admin_GetFeaturedContrib]ASBEGINDECLARE @FeaturedContrib TABLE ( UserID INT, Category INT, Title varchar(100), Summary varchar(200), DatePosted date, FirstName varchar(50), LastName varchar(50), Picture varchar(100))INSERT INTO @FeaturedContribSELECT TOP 6 ContribContent.UserID, ContribContent.Category, ContribContent.Title, SUBSTRING(ContribContent.Article, 0, 200) AS Summary, ContribContent.DatePosted, Users.FirstName, Users.LastName, Users.PictureFROM ContribContentINNER JOIN UsersON ContribContent.UserID = Users.UserIDWHERE ContribContent.DateFeatured IS NOT NULLORDER BY ContribContent.DateFeatured DESCSELECT * FROM @FeaturedContribEND涉及两个数据表:用户-存储所有用户及其信息的表。用户ID INT名字varchar(50)姓氏varchar(50)图片varchar(50)等等...贡献内容ContribContentID INT用户ID INT类别INT标题varchar(100)文章varchar(MAX)图片varchar(50)日期发布日期日期特色日期删除位感谢任何可以提供帮助的人! (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 仅运行-SELECT TOP 6 ContribContent.UserID, ContribContent.Category, ContribContent.Title, SUBSTRING(ContribContent.Article, 0, 200) AS Summary, ContribContent.DatePosted, Users.FirstName, Users.LastName, Users.PictureFROM ContribContentINNER JOIN UsersON ContribContent.UserID = Users.UserIDWHERE ContribContent.DateFeatured IS NOT NULLORDER BY ContribContent.DateFeatured DESC查看您得到的Where可能是什么问题,或者join仔细查看是否首先返回任何数据。我的猜测是join看看您要加入的用户ID是否匹配...(提示:左加入也许是您的答案) (adsbygoogle = window.adsbygoogle || []).push({}); 07-26 09:36