我正在尝试从名为 address_contact 的表中获取最后一个 ID#,我使用的代码是:
$result = mysql_query("SELECT id FROM address_contact ORDER BY lastUpdate DESC LIMIT 1")
or die(mysql_error());
$row = mysql_fetch_array( $result );
$id = .$row['id'];
现在我想关闭该连接并打开一个新连接,然后使用我们刚刚获得的 ID# 从以下 3 个表中获取所有数据:
Table 1: address_address
Table 2: address_contact
Table 3: address_email
所以它看起来像这样???
$result = mysql_query("SELECT address_contact.id,address_contact.lastname,address_contact.firstname,address_contact.primaryAddType,address_address.id,address_address.phone1,address_address.phone2,address_address.line2,address_email.id,address_email.email
FROM address_address
LEFT JOIN address_contact ON address_address.id=address_contact.id
LEFT JOIN address_email ON address_address.id=address_email.id
WHERE address_contact.id = ".$id)
但是必须有一种更简单/更快的方法来做到这一点?