[英]Query selecting from two tables
i am having trouble with what seems quite a simple select query, i know there are lots of tutorials out there for this, but none seem to work for me, i keep getting the 我在处理似乎很简单的选择查询时遇到了麻烦,我知道这里有很多教程,但是似乎对我没有用,我一直在
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given 警告:mysql_fetch_assoc()期望参数1为资源,给定布尔值
Error 错误
Here is the query causing it, basically i just want to select from 2 different tables 这是引起它的查询,基本上我只想从2个不同的表中选择
$trash_statement = "SELECT * FROM user_inbox, user_outbox WHERE user_inbox.receiver_user_id='$user_id' AND user_outbox.sender_user_id='$user_id' AND mail_deleted='1'";
Any ideas, where i am going wrong? 任何想法,我要去哪里错了?
Thanks 谢谢
mail_deleted is not associated with any table name! mail_deleted没有与任何表名关联! That causes Mysql to return an error and not a resource as expected by mysql_fetch_assoc() .
这导致Mysql返回错误,而不是mysql_fetch_assoc()期望的资源。
MySql Error: saying that the field name is not related to anything MySql错误:说字段名称与任何东西都不相关
#1052 - Column 'mail_deleted' in where clause is ambiguous
YOUR QUERY 您的查询
$trash_statement = "
SELECT *
FROM user_inbox, user_outbox
WHERE user_inbox.receiver_user_id='$user_id'
AND user_outbox.sender_user_id='$user_id'
AND yourTableName.mail_deleted='1'";
FIX THIS: 解决这个问题:
... yourTableName .mail_deleted... ... yourTableName .mail_deleted ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.