SELECt p.id, g.typeid, g.id, g.title
FROM products p
INNER JOIN (SELECt * FROM gallery a
WHERe (SELECt COUNT(*) FROM gallery b WHERe b.title = a.title AND b.id >= a.id) <= 2
) g ON p.id = g.typeid
WHERe p.id in (3,4,5)
编辑:
SELECt p.id, g.typeid, g.id, g.nameFROM products p INNER JOIN (SELECt * FROM gallery a WHERe (SELECt COUNT(*) FROM gallery b WHERe b.typeid = a.typeid AND b.id >= a.id) <= 2) g ON p.id = g.typeid WHERe p.id in (3,4,5) order by g.id asc
所以基本上这部分
WHERe (SELECt COUNT(*) FROM gallery b WHERe b.title = a.title AND b.id >= a.id) <= 2
用于替换
group by typeid
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)