首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mysql嵌套查询故障

问Mysql嵌套查询故障
EN

Stack Overflow用户
提问于 2012-10-06 03:36:19
回答 1查看 74关注 0票数 0

我已经创建了一个带有嵌套select语句的mysql seect语句。现在我的mysql技能(或者说缺乏)非常有限。下面是我写的代码。我得到的结果是空白或者是警告。mysql_fetch_Array错误。谢谢你的帮助。

代码语言:javascript
复制
 <?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;

?>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-08 05:12:03

您是否尝试过仅执行子查询,以查看实际返回了多少条记录,并确保实际设置了$memberId?

对于用户来说,拥有多个集合是有意义的,因此您可能应该调整您的主查询,以便在子查询结果上使用IN而不是=。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12752930

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档