2

I have 2 tables in MySQL, one is application the other application_storefront. They look like this:

application:

application_id | title           
------------------------------------
529479190      | Clash of Clans  
553834731      | Candy Crush Saga

and the table application_storefront which is the countries the applications are available in:

application_id | country_code
--------------------------------
529479190      | USA
529479190      | GBR
529479190      | AUS

I want to create a view or a new table with each country code as a column and then flag if the application is available in that country e.g.

application_id | title           | USA | GBR | AUS | etc...
--------------------------------------------------------
529479190      | Clash of Clans  |  1  |  1  |  0  | etc...

How do you achieve this in MySQL?

Ric Moore
  • 71
  • 4
  • 1
    It's often called a pivot, http://stackoverflow.com/questions/7674786/mysql-pivot-table – Robert Dupuy Sep 20 '15 at 15:25
  • 196 countries in the world. keep that in mind for table columns and accessing those by name. that would be a non-starter for me – Drew Sep 20 '15 at 15:26

0 Answers0