gpt4 book ai didi

php - 为什么第二个连接在我的查询中不起作用?

转载 作者:行者123 更新时间:2023-11-29 13:44:19 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row()/mysql_num_rows etc... expects parameter 1 to be resource

(31 个回答)


8年前关闭。




我在这个网站上搜索过,看不到任何明显我做错的事情,但我的查询不起作用并返回 警告:mysql_fetch_array() 期望参数 1 是资源, 中给出的 bool 值错误

$sql2 = "SELECT users.user_id, users.username, users.profile, post_id, post_content, post_date, post_topic, post_by, topics.category, topic.sub_category
FROM `posts`
JOIN `users` on posts.post_by = users.user_id WHERE post_topic='$id'
JOIN `topics` on posts.post_topic = topics.topic_id";

最佳答案

join所有表格,然后 添加您的where健康)状况

SELECT u.user_id, u.username, u.profile, 
p.post_id, p.post_content, p.post_date, p.post_topic, p.post_by,
t.category, t.sub_category
FROM `posts` p
JOIN `users` u on p.post_by = u.user_id
JOIN `topics` t on p.post_topic = t.topic_id
WHERE p.post_topic='$id'

关于php - 为什么第二个连接在我的查询中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17640435/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com