MySQL Left Join Subselect?

There might be a better way of doing this, and I haven't tested it in MySQL, but the following works in SQL Server 2005: Select a. Language, b. Template, count (c.

Template) as combo_count from (select distinct language from tablename) as a inner join (select distinct template from tablename) as be on 1 Language and c. Template = b. Template group by a.

Language, b. Template order by 1, 2 Here are the results with your sample data: au t1 0 au t2 1 au t3 0 en t1 3 en t2 0 en t3 0 ge t1 0 ge t2 1 ge t3 2.

Perfect, just what I was after and works fine in MySQL. Thanks for your help. – StuR Sep 22 at 21:57.

Select a. Language, a. Template, Count(*) count From (Select Distinct language, template From table) a Left Join table be On b.

Language = a. Language And b. Template = b.

Template Group By a. Language, a.template.

I've given this a try although am still getting the same as I would using the query in my above comment (no zero values). Also, why group first on language shouldn't it be a. Template, a.

Language? – StuR Sep 22 at 20:25.

What you need is two tables that list the possible values for language and template. CREATE TABLE language (...) AS SELECT DISTINCT language FROM your_table; CREATE TABLE template (...) AS SELECT DISTINCT template FROM your_table; Then you can do something like this: SELECT l. Language, t.

Template, SUM(CASE WHEN yours. Language IS NULL THEN 0 ELSE 1 END) count FROM language l CROSS JOIN template t LEFT OUTER JOIN your_table yours ON l. Language = yours.

Language AND t. Template = yours. Template GROUP BY l.

Language, t.template.

I've given this a go although I get the same results as in the below answer. – StuR Sep 22 at 21:46.

Inner join (select distinct template from tablename) as be on 1 Language and c.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions