I need to create a new table, based on two existing. http://sqlfiddle.com/#!9/74e49 It must contain number of instances of every particular value from table1 in table2. Like:
- Name - koatuu1 - koatuu2 - koatuu3 - koatuu_N ... koatuu_350
- Johnson - 5 - 12 - 76 - 9 - 321 - 4
It must be something like this for every lastname:
select table1.koatuu, count(table2.*)
from table2
where lastname = "Johnson"
inner join table1 on table1.postcode = table2.postcode
I need a red circled table Can I do it within MySQL query, without writing a script in Php?