PDA

View Full Version : Help with this query


ARP
01-14-2012, 03:06 PM
I'm confused due to this query, It's showing the results repeated 3 times


SELECT post.postid, post.dateline, post.threadid, post.userid, post.username, thread.title, thread.firstpostid, thread.postuserid, thread.forumid
FROM post AS post
JOIN thread AS thread ON ( thread.postuserid = post.userid )
WHERE post.userid =1
AND thread.visible =1
AND post.visible =1
AND thread.open =1
ORDER BY post.dateline DESC
LIMIT 0 , 200


If you tried it from your phpmyadmin you will see the same postid with different titles and with different firstpostid

So where is the problem ?

kh99
01-14-2012, 03:19 PM
So you're saying that query works correctly from phpmyadmin? Is it possible it's actually a problem in the rest of the code and not the query itself?

ARP
01-14-2012, 03:22 PM
No, The same query doesn't work from phpmyadmin it given the same 3 repeated postids with different titles and different firstpostid

There's a problem in the query itself

kh99
01-14-2012, 03:29 PM
Hmm...OK, I think you want to join ON ( thread.threadid = post.threadid ). I think maybe what you have is repeating the post info for each thread the post author has started, or something like that.

ARP
01-14-2012, 03:33 PM
Works fine, Thanks :)