且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL - 根据日期和类别拉取列表

更新时间:2023-12-02 17:07:10

您必须对来自 CategoryID 字段的两个选择的结果进行交叉.我认为这应该有效:

You must cross the results from both selects on the CategoryID field. I think this should work:

SELECT DISTINCT PosterID
FROM table1 x
WHERE PostingDate BETWEEN '2012-05-01' AND '2012-06-30'
AND posterID NOT IN (SELECT PosterID
  FROM table1 y
  WHERE PostingDate > '2012-07-01' AND x.CategoryID = y.CategoryID);