This is most likely a simple question, but I have no idea how to solve it.
In this scenario, I have three tables. Events, ads and visits. Ads and visits both have event_id fields, and visits has an ad_id field. In the end, we want to compare two event dates.
Based on the id of an ad, i need to get all visits, where their event’s date is later than the ad’s event date.
I would love to provide some code, but in this case I’m pretty lost, I have no idea how to do joins upon joins like that.
Thanks.
The trick here is putting a condition in the
onclause of the join to the visit’s event comparing with the ad’s event.Note too that the same table can be joined more than once by assigning different table aliases.