I have 2 tables of data that are category (category table) and video (Video table) as the image below. I was querying as this picture (Query mysqli test) to get the video and its catalog. Is there a way I can use only one query but still have the same result as the current query?
<?php
include('config.php');
$page=intval($_REQUEST['page']);
$limit=10;
$start=$page*$limit - $limit;
$video=mysqli_query($conn,"SELECT * FROM video ORDER BY video_id DESC LIMIT $start,$limit");
while($r_video=mysqli_fetch_assoc($video)){
$cat_info=mysqli_query($conn,"SELECT * FROM category WHERE cat_id IN ({$r_video['video_cat']}) ORDER BY cat_sort ASC");
while($r_cat=mysqli_fetch_assoc($cat_info)){
$list_cat.='<a href="/category/'.$r_cat['cat_name'].'.html">'.$r_cat['cat_name'].'</a>,';
}
$list_cat=substr($list_cat, 0,-1);
echo $r_video['video_name'].'<br>'.$list_cat;
unset($list_cat);
}
?>