如何显示来自所有表(相同结构)的查询并按数据排序


How to show query from all the tables(same structure) and order all by data

我想知道如何从多个表中选择要显示的查询,然后按数据排序,并将其限制为一个数字(如果我设置limit 5,则只显示所有表中最近的按数据添加的5查询,而不是其中一个表的最近添加的5,因为我想像新闻栏一样制作)我有5个具有相同结构的表(类别)(id、title、describer、poza、data),我只想显示它们中的最后5个。

//create connection to mysql
$db_conx_index = mysqli_connect($servername, $username, $password, $dbname);
$db_conx_index->set_charset('utf8');// pentru diacritice
if(!$db_conx_index){
 die("Connection failed: ". mysqli_connect_error());
}
$catArray = array("istorie", "lifestyle", "sciente", "travel", "nature");    
$slider = '';
foreach($catArray as $k=>$v)
{    
    $sql = "SELECT id, titlu, data, linknews, poza FROM ".$v."  WHERE approved='1' ORDER BY data DESC LIMIT 5";
    $query = mysqli_query($db_conx_index, $sql);   
    while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
        $id = $row["id"];
        $titlu = $row["titlu"];
        $linknews = $row["linknews"];
        $poza = $row["poza"];
        $slider .= '<a href="/'.$linknews.'"><img src="/images/'.$poza.'-600x.jpg" alt="'.$titlu.'"></a>';
    } 
}
?>  
     <?php echo $slider;?> 
    <?php mysqli_close($db_conx_index);?> 

但代码显示了每一个表的最后5个查询,并按顺序排列,然后是secont表。。并且想要在不考虑计算的情况下订购第一个表格。。。。

忘记foreach循环。

"SELECT id, titlu, data, linknews, poza FROM istorie, lifestyle, sciente, travel, nature  WHERE approved='1' ORDER BY data DESC LIMIT 5"