您需要为子查询添加别名,并且需要将条件应用于您合并的两个查询:
SELECt MAX(DateTime)FROM ( SELECt DateTime FROM Class_Searches WHERe User_Email = 'bla@blah.com' AND DateTime > NOW( ) - INTERVAL 30 DAY UNIOn ALL SELECt DateTime FROM Book_Searches WHERe User_Email = 'bla@blah.com' AND DateTime > NOW( ) - INTERVAL 30 DAY) AS x
或返回数据,以便您可以在外部查询中应用条件:
SELECt MAX(DateTime)FROM ( SELECt DateTime, User_Email FROM Class_Searches UNIOn ALL SELECt DateTime, User_Email FROM Book_Searches) AS xWHERe User_Email = 'bla@blah.com'AND DateTime > NOW( ) - INTERVAL 30 DAY
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)