I have a table as T1 and table as T2 like the following:
T1
-------------------------------------------------------
id | price | email
-------------------------------------------------------
1 | $1000 | jacky@domain.com
2 | $2000 | angle@domain.com
3 | $3000 | kevin@domain.com
-------------------------------------------------------
T2
-------------------------------------------------------
id | master | country | key | value
-------------------------------------------------------
1 | 1 | US | price | $399
2 | 1 | US | email | jacky/domain.us
3 | 1 | ES | price | $550
4 | 1 | ES | email | jacky@domain.es
5 | 1 | JP | price | $820
6 | 1 | JP | email | jacky@domain.jp
7 | 2 | US | price | $360
8 | 2 | US | email | angle@domain.us
-------------------------------------------------------
How to get this result:
T3
----------------------------------------------------------------------------------------------------------------------------
id | price | price_US | price_ES | price_JP | email | email_US | email_ES | email_JP
----------------------------------------------------------------------------------------------------------------------------
1 | $1000 | $399 | $550 | $820 | jacky@domain.com | jacky@domain.us | jacky@domain.es | jacky@domain.jp
1 | $2000 | $360 | NULL | NULL | angle@domain.com | angle@domain.us | NULL | NULL
1 | $3000 | NULL | NULL | NULL | NULL | NULL | NULL | NULL
----------------------------------------------------------------------------------------------------------------------------
Or can I get this result in PHP?
T4
-------------------------------------------------------
id | price | email | more_info
-------------------------------------------------------
1 | $1000 | jacky@domain.com | [array (rows...)]
2 | $2000 | angle@domain.com | [array (rows...)]
3 | $3000 | kevin@domain.com | [array (rows...)]
-------------------------------------------------------
Any idea?
EDIT 1
Or can I get the result as the following?
T5 (US of country's result)
-------------------------------------------------------
id | price | email
-------------------------------------------------------
1 | $399 | jacky@domain.us
2 | $360 | angle@domain.us
3 | $3000 | kevin@domain.com
-------------------------------------------------------
T6 (JP of country's result)
-------------------------------------------------------
id | price | email
-------------------------------------------------------
1 | $820 | jacky@domain.jp
2 | $2000 | angle@domain.com
3 | $3000 | kevin@domain.com
-------------------------------------------------------