$query = "SELECT name,rant,rating FROM rants ORDER by Id DESC ";
这是一个表的查询,我需要从同一个数据库中的两个表中提取信息,但我不想继续创建新的查询,例如。 $ query1,$ query2,$ query3 ...
是否可以将其全部写在一行中,例如。在引用之间还是我必须为每个表创建单独的查询?
更新
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR.'dbconnect.php');
$link = new mysqli("$servername", "$username", "$password", "$dbname");
$query = "SELECT COUNT(*) FROM rants";
if ($result = $link->query($query)) {
/* fetch object array */
while ($row = $result->fetch_row()) {
if($row[0]==0){
echo "There are no entries.";
}else {
$query2 = "SELECT name,rant,rating FROM rants ORDER by Id DESC ";
if (($result = $link->query($query2))) {
/* fetch object array */
while ($row = $result->fetch_row()) {
}
}