PUT 2 mysql表一起显示结果

时间:2013-09-22 09:32:17

标签: php mysql

我怎么能把这两张桌子放在一起

$result = mysql_query("SELECT * FROM berichten where fromm='$id' AND ontvanger =     '$session->username'  ORDER BY date ASC");


$result = mysql_query("SELECT * FROM berichten_send where fromm='$id' AND ontvanger =     '$session->username'  ORDER BY date ASC");

这是我尝试过的但不是没有用的

$result = mysql_query("SELECT * FROM berichten LEFT JOIN berichten_send on berichten.id =     berichten_send.id where fromm='$id' AND ontvanger = '$session->username'  ORDER BY date ASC");
$number=mysql_num_rows($result);



while($row = mysql_fetch_array($result))
{

echo $row['msg'];
echo "<br>";
echo time_stamp($row['date']);
echo "<br>-----------------------<br>";

}  

1 个答案:

答案 0 :(得分:0)

问题的最初部分显示两个表都有'fromm'和'ontvanger'字段。

mysql应该抱怨模糊的字段。

尝试

.... where berichten.fromm='$id' AND berichten.ontvanger = '$session->username'