Wednesday, 28 August 2013

Group by column and display count from all tables in mysql

Group by column and display count from all tables in mysql

I have two tables: Table1 looks like this:
id type
1 bike
2 car
3 cycle
4 bike
And Table2 looks like this:
id type
1 bike
2 car
I want my final output to look like the following:
type count_table1 count_table2
bike 2 1
car 1 1
cycle 1 0
What is the most efficient way to do this in SQL?

No comments:

Post a Comment