2013-07-14 3 views
0

이 사이트에서 검색 한 내용이 잘못되었지만 내 쿼리가 작동하지 않고 반환되지 않습니다. 경고 : mysql_fetch_array()는 매개 변수 1이 리소스가 될 것으로 예상하고 부울은 오류를 나타냅니다.두 번째 조인이 내 쿼리에서 작동하지 않는 이유는 무엇입니까?

$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"; 

답변

1

먼저 join 모든 테이블, 다음 다음에 phpMyAdmin에 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' 
+0

그건 그랬어, 고마워. :) – user2571547

0

시도를 추가하고 PHP 코드에 붙여 복사, 당신은 걱정하지 않아도 PHP에서 사용할 때 잘못된 쿼리에 관해서.

관련 문제