表2中由于数十万记录而花了很长时间
SELECT t1.id,
( SELECT MAX(paid_date) FROM t2
where t1.id = t2.due_id
t2.deleted_at IS NULL
) as lastPaidDate
WHERE t1.deleted_at IS NULL
在这里,我试图从表T2获得最大日期,其中表T1.ID = t2.due_id,但在表T2中有很多记录,即一到很多关系,我只想从T2开始,这需要很长时间
SELECT t1.id,
( SELECT MAX(paid_date) FROM t2
where t1.id = t2.due_id
t2.deleted_at IS NULL
) as lastPaidDate
WHERE t1.deleted_at IS NULL
Here I am trying to get max date from table t2 where table t1.id = t2.due_id but in table t2 there are many records i.e one to many relationship, I want only max date from t2,It is taking very long time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论