In wordpress, custom posts are locked in the
wp_posts table, as well as their ID is recommended in another table
wp_meta using the following posts
post_id, meta_key, meta_value
Let us say I've got a recipe known as
wp_posts, as well as in
wp_meta I've 3
meta_keys: "time_for_preparation", "ingredients", "difficulty"
How do you write a mysql query that returns us a single row using the 3 meta_secrets?
Basically do an inner join I'll just see 3 teams of "pudding", each with similar
wp_posts data and something different meta_key
Things I want is really a single row of
pudding together with meta_secrets
can that be achieved?
create table wp_post ( id int identity(1,1), name nvarchar(200) ) create table wp_meta ( id int identity(1,1), postid int, metaname nvarchar(200) ) insert into wp_post select 'Apple' insert into wp_meta select 1,'red' select * from wp_post select * from wp_meta select * ,stuff((select ', ' +metaname from wp_meta where postid=w.id for xml path('')), 1, 1,' ') from wp_post as w
this really is all made by me in MS SQL Server
for altering this into you can observe this publish that have for MYSql how-do-i-create-a-comma-separated-list-using-a-sql-query
when i do not have mysql however i attempted to transform this using the url which i've recommended you and so i think this is in mysql like below
SELECT w.name, GROUP_CONCAT(m.meta_key, ',') FROM wp_post w JOIN wp_meta m ON m.post_id= w.id GROUP BY w.name