I want to count the number of times a certain fields have particular values. I tried using a union (which works in SQL Server) but it doesn't work in mySQL. All i get is a syntax error.
The correct way to do this or a better way would be appreciated.
select count(*) as count1 from projects where proj_type = '1'
union
select count(*) as count2 from projects where proj_type = '2'
union
select count(*) as count3 from projects where proj_type = '3'
union
select count(*) as count4 from projects where proj_type = '4'
The correct way to do this or a better way would be appreciated.
select count(*) as count1 from projects where proj_type = '1'
union
select count(*) as count2 from projects where proj_type = '2'
union
select count(*) as count3 from projects where proj_type = '3'
union
select count(*) as count4 from projects where proj_type = '4'