Mysqli LEFT JOIN计数

时间:2015-11-06 20:48:01

标签: php mysql mysqli left-join

我在mysqli真的很棒,所以我需要帮助..

请帮我将此mysql转换为mysqli ...我无法弄清楚..

$new_mail = mysql_result(
                  mysql_query(
                       "SELECT COUNT(*) FROM `mail` 
                           LEFT JOIN `contact` ON `mail`.`user_id` = `contact`.`from_id` 
                                              AND `contact`.`user_id` = '$user_id 
                        WHERE `mail`.`from_id` = '$user_id' 
                          AND `mail`.`read` = '0' 
                          AND `mail`.`delete` != '$user_id' 
                          AND `contact`.`ban` != '1'")
               , 0);
if ($new_mail)
    $list[] = '<a href="link">Message - $new_mail </a>'

1 个答案:

答案 0 :(得分:0)

我转换了... tnx无论如何:)

$new_mail = mysqli_fetch_array(mysqli_query($db, "SELECT COUNT(*) FROM `mail` LEFT JOIN `contact` ON `mail`.`user_id`=`contact`.`from_id` AND `contact`.`user_id`='$user_id' WHERE `mail`.`from_id`='$user_id' AND `mail`.`obrisano`!='$user_id' AND `contact`.`ban`!='1'"));

@ryan我只是想将mysql查询转换为mysqli,但tnx:)