May I know if I can combine queries from different variable or is there any other way. I want to insert $query_1 to $query_2
Example:
$sql = "SELECT l_id from mlk";
$result = mysqli_query($conn, $sql);
$count = mysqli_num_rows($result);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
$l_id[] = $row["l_id"];
}
}
mysqli_free_result($result);
foreach($l_id as $row){
$query_1= "(select count(*) from staff s where s.l_id = $row) as mlk_$row,";
}
$query_2= "SELECT mlk.lokasi,
//insert $query_1 here
from mlk INNER JOIN staff WHERE staff.l_id=mlk.l_id GROUP BY mlk.lokasi";
$result = mysqli_query($conn, $sql);
mlkis a table that stores staff working location$query_2will display the Location Name and I also want to display the total number of staff on that particular location. eg,Kuala Lumpur, 10