declare @PageCount int,
@TopicId int,
@Num int
BEGIN
select
distinct
top 6
t.topicid,
t.title,
isnull(t.pic,'../images/pic003.jpg') as pic
from
dbo.T_Novel_Topic t,
dbo.T_Books_Order o
where
o.OrderType=2 and
o.UserId in (select UserId from dbo.T_Books_Order where BooksId=1) and
o.BooksId <> 1 and
o.BooksId not in (select Top (6*0) BooksId from dbo.T_Books_Order where UserId in(select UserId from dbo.T_Books_Order where BooksId=1)) and
o.BooksId=t.topicid and
o.Status=1
END
红字的那个地方有问题呀 如果 6*1 显示的条数 跟6*2一样
@TopicId int,
@Num int
BEGIN
select
distinct
top 6
t.topicid,
t.title,
isnull(t.pic,'../images/pic003.jpg') as pic
from
dbo.T_Novel_Topic t,
dbo.T_Books_Order o
where
o.OrderType=2 and
o.UserId in (select UserId from dbo.T_Books_Order where BooksId=1) and
o.BooksId <> 1 and
o.BooksId not in (select Top (6*0) BooksId from dbo.T_Books_Order where UserId in(select UserId from dbo.T_Books_Order where BooksId=1)) and
o.BooksId=t.topicid and
o.Status=1
END
红字的那个地方有问题呀 如果 6*1 显示的条数 跟6*2一样
declare @PageCount int,
@TopicId int,
@Num int
BEGIN
select
distinct
top 6
t.topicid,
t.title,
isnull(t.pic,'../images/pic003.jpg') as pic
from
dbo.T_Novel_Topic t,
dbo.T_Books_Order o
where
o.OrderType=2 and
o.UserId in (select UserId from dbo.T_Books_Order where BooksId=1) and
o.BooksId <> 1 and
-- o.BooksId not in (select Top (6*0) BooksId from dbo.T_Books_Order where UserId in(select UserId from dbo.T_Books_Order where BooksId=1)) and
o.BooksId=t.topicid and
o.Status=1
END
--测试2
select Top (6*1) BooksId from dbo.T_Books_Order where UserId in(select UserId from dbo.T_Books_Order where BooksId=1)--测试3
select Top (6*2) BooksId from dbo.T_Books_Order where UserId in(select UserId from dbo.T_Books_Order where BooksId=1)
应该是order by的问题
加上order by BooksId 试试
里面有null值,任何数和null比较都是 false ,所以任何数都不回返回