我已经创建了一个带有嵌套select语句的mysql seect语句。现在我的mysql技能(或者说缺乏)非常有限。下面是我写的代码。我得到的结果是空白或者是警告。mysql_fetch_Array错误。谢谢你的帮助。
<?php
session_start();
$memberId = $_GET['id'];
$loggedId = $_SESSION['id'];
include('../connect_DB.php');
$sql = 'SELECT bins.tag_Id, tagging_Info.plant_Id, tagging_Info.photo_Id FROM bins inner join tagging_Info on bins.tag_Id = tagging_Info.tag_Id inner join collections on collections.id = bins.collection_Id WHERE collections.member_Id ='.$memberId.' and collections.id=(SELECT id FROM collections where member_Id='.$memberId.')';
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$collection = "Success"; // test to see if working
}
echo $collection;
?>发布于 2012-10-08 05:12:03
您是否尝试过仅执行子查询,以查看实际返回了多少条记录,并确保实际设置了$memberId?
对于用户来说,拥有多个集合是有意义的,因此您可能应该调整您的主查询,以便在子查询结果上使用IN而不是=。
https://stackoverflow.com/questions/12752930
复制相似问题