56,940
社区成员




-- 首先涉及三张表
-- 表1 Paper(paperID,content)
-- 表2 Tag(tagID,tagName)
-- 表3 TestTag(paperID,tagID) 表1和表2 之间为多对多关系此为关系表
-- 下面是存储过程中的部分内容:
select concat('select SQL_CALC_FOUND_ROWS a.* from TestTag b
join TestTag c on b.paperID=c.paperID and b.tagID<>c.tagID
join TestTag d on b.paperID=d.paperID and b.tagID<>c.tagID and b.tagID<>d.tagID
join TestTag e on b.paperID=e.paperID and b.tagID<>c.tagID and b.tagID<>d.tagID and b.tagID<>e.tagID
join TestTag f on b.paperID=f.paperID and b.tagID<>c.tagID and b.tagID<>d.tagID and b.tagID<>e.tagID and b.tagID<>f.tagID
join paper a on a.paperID=b.paperID where b.tagID=? and c.tagID=? and d.tagID=? and e.tagID=? and f.tagID=? ',conditions,' ',orderBy,' ',orderType,' limit ?,?') into @sqlstr;
PREPARE stmt1 FROM @sqlstr;
EXECUTE stmt1 USING @t1,@t2,@t3,@t4,@t5,@a,@b;