php - Selecting rows from multiple tables -


i know fastest way make following sql call using php. using procedural mysqli.

$dcount = "select max(id) deposits"; $result = mysqli_query($conn,$dcount); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) {     $count = $row["max(id)"];     echo $count;     echo ",";  } } else { echo '0'; }  //second query $ucount = "select max(int) anothertable"; $result2 = mysqli_query($conn,$ucount); if (mysqli_num_rows($result2) > 0) { while($row = mysqli_fetch_assoc($result)) {     $count = $row["max(int)"];     echo $count;     echo ",";  } } else { echo '0'; } 

is there way make execution faster this, maybe echo results both queries after first if statement?

it seems rather long me.

thanks in advance.

$dcount = " select max(id) max,'deposit' table_name deposits union select max(id) max,'another' table_name anothertable ";   $result = mysqli_query($conn,$dcount); if (mysqli_num_rows($result) > 0){   while($row = mysqli_fetch_assoc($result)){     echo $row["table_name"].":".$row["max"]."\n";   } } else {   echo '0'; } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -