Combining query results


I recently got assistance in the mysql forum on how to build a report that shows forum usage statistics over a period of 12 months.  So now I have 2 queries that give me the data, but to output the report properly I need this data to be in 1 result set.  So my question is if I have 2 queries, each returning 2 columns- how do I combine the results into a result set with 3 columns when 1 column is common between the 2 queries?

Month | Topics
Aug    |  14
Sept   |   0
Oct     |  34


Month | Posts
Aug    |   5
Sept   |   17
Oct     |  20


Month | Posts  |  Topics
Aug    |   5    |   14
Sept   |   17   |   0
Oct     |  20   |   34

Any ideas?
Who is Participating?

for($k=0; $k < mysql_num_rows($res); $k++){
        $res2=mysql_query(SELECT TOPICS FROM query2 WHERE Month='$Month')


Is this what you looking for?

SELECT Topics, Posts FROM tbl_topic, tbl_post GROUP BY Month
Mr_ShadowAuthor Commented:
well not really, im not looking to alter my queries, lets say i have query 1 which produces columns A and B.  I have query 2 which produces columns A and C.  I need 1 query object that has A, B, and C.  The question is is there any way to manipulate queries in this way in PHP.  I know the obvious answer is 'make the database do it in one query', well assuming i absolutely cannot, is there any way php can help.
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Hmm... I think the only way to combine the query result of A,B and C is to alter your 2 queries and make it into 1 query like how i did it in the first post. If you would like to combine the two using PHP, I must say it's a mission, as you need to synchronize the rows so they match up. Another thing is that, you won't be able to do an ORDER BY if you have 2 queries forced into 1 query result, I suppose you can, but with extra extra coding and difficult to track errors.
I wasn't ready there
But I think the idea is clear, just query for your topics within the loop where you get your results from query1.
Then you have all the info together to list in a single line.
If that's what you are looking for.
Mr_ShadowAuthor Commented:
sorry for my unresponsiveness, i have since hired a programmer to get this information from 1 query- i have sent him InvolveIT's response as a possible way to do it, since he also says it is impossible with 1 query.  thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.