In Postgres I've got two different tables that have almost nothing in common, save for the fact that they both have a creation date. I'd like to use that creation date in order to display instances of both of those models on a timeline. To do that, I imagine I need to first somehow select all of the created_at timestamps from BOTH of the tables in one statement, then sort them in descending order, paginate the resulting set, and then go through and detect which model each of the rows corresponds to in order to properly display the data.
Any idea if this is possible?
Maybe smth like this
select created_at, 'a' as tab_name from table_a
union all
select created_at, 'b' as tab_name from table_b
order by created_at
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With