the db is structured as follows:
id | meta-key | meta-value
1 | client | John
1 | bday | today
i want it to be
id | client | bday
1 | John | today
there are many lines like client and bday and i want to transform some of them into columns either when displaying or inserting into another table
i tried something like this:
SELECT p1.meta_value, wph0_posts.post_title, p2.meta_value as client, p3.meta_value as end_date, p4.meta_value as description
FROM wph0_postmeta p1
INNER JOIN wph0_posts ON p1.post_id = wph0_posts.ID
INNER JOIN wph0_postmeta p2 ON
p1.post_id = p2.post_id AND
p2.meta_key = 'client'
INNER JOIN wph0_postmeta p3 ON
p1.post_id = p3.post_id AND
p3.meta_key = 'end_date'
INNER JOIN wph0_postmeta p4 ON
p1.post_id = p4.post_id AND
p4.meta_key = 'description';
can i get some tips? pretty new to db'es