PDA

View Full Version : Query to combine 2 tables?


HakkieDEV
06-18-2004, 10:06 PM
Hi all,

I am using a postcounthack (the one of touchingvirus) and I wanted to show on forumhome the top10threadstarters in a specific forumid.

Well, this query works and shows the statistics of the members:

$stats10 = $DB_site->query('SELECT
`threadcount`.`userid`,`threadcount`.`count1`,
`user`.`userid`,`user`.`username` FROM threadcount, user
Where `user`.`userid`=`threadcount`.`userid` ORDER BY
`threadcount`.`count1` DESC LIMIT 0,10');

However, while it shows the threadcount, it doesn't link the userid to the username. (And, the username isn't being stored in the threadcount-table)

So, how do I combine this query with the user-table to display the username next to the threadcount?

HakkieDEV
06-21-2004, 06:56 PM
I guess I wasn't really clear about what I would like to do, so I hope this info will make it a bit easier to help me. :)

I'm trying to combine 2 tables like this:

I have 2 tables, postcount and user
postcount has field userid
user has field userid
user has field username

How do I combine these so I can display the username together with the postcount for each userid?

I tried to do:

$postcountuser = $DB_site->query("
SELECT userid, user FROM postcount, user where user.username=postcount.username
order BY username");




But, mysql considers this ambigious.
What am I doing wrong here?