Multiple tables query the last 100 pieces of data?

  1. how do I query the last 100 pieces of data in multiple tables in the ORACLE database? For example, the two tables of An and B have a time field, and the last 100 items of data in tables An and B are not the last 100 items in An and B.
Mar.07,2021

  1. query the first 100 items of data in tables An and B to form a temporary table, and then pass the temporary table through time Filter.

--sqlserver

-- A  B [Id][Time] 

SELECT TOP 100 [Id],[Time] FROM
(
        SELECT [Id],[Time] FROM [Table_A] 

        UNION ALL

        SELECT [Id],[Time] FROM [Table_B] 

) [NewTable_V]

ORDER BY [Time] DESC

I don't know if SQL itself has any good methods, but we can work around it:
find the last 100 items of data in two tables, then these 100 items of data must be in the first 100 items of An and B.
is simple enough to find the first 100 pieces of data for An and B, and then sort them in the business logic.


use two tables union to combine the last hundred pieces of data to form a temporary table

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3db2f-44749.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3db2f-44749.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?