I am tring to export some data from a wordpress plugin that save 3 custom filed (name, surname and email) in multiple rows. Every filed have a "meta_key" to identify it (so it is "simple" to understand the field name) but in my DB I need a single row with multiple columns.
Example:
WP database (named "table_postmeta")
post_id | meta_key | meta_value
1 | 7a4 | Name1
1 | f53 | Surname1
1 | 8ff | test1@test.com
2 | 7a4 | Name2
2 | f53 | Surname2
2 | 8ff | test2@test.com
3 | 7a4 | Name3
3 | f53 | Surname3
3 | 8ff | test3@test.com
My table (named "users", I will create a copy of _postmeta table in my db so I always have a clear copy):
post_id | Name | Surname | Mail
1 | Name1 | Surname1 | test1@test.com
2 | Name2 | Surname2 | test2@test.com
3 | Name3 | Surname3 | test3@test.com
Is there a way to do this with mysql or it is better to do a php script?
Thanks!