mysql - Return all joined rows in SQL -


so messing around wordpress , trying rows row joins to. now, can seem 1 row joins to. know there has element of group by, can't seem figure out.

select posts.*, meta.meta_value                 wp_g6exrf_posts posts                 left outer join wp_g6exrf_postmeta meta                 on meta.post_id = posts.id                 ! ( posts.post_status = 'auto-draft' )                  group meta.post_id 

so joining meta table , expecting more 1 column meet join condition.

sincere help. appreciated.

postmeta makes little sense without seeing meta_key.

group doesn't make sense unless you're doing kind of aggregate. it's crushing multiple rows each post one, , returning 1 of meta_value items, randomly chosen one.

try this:

select posts.*,         meta.meta_key, meta.meta_value   wp_g6exrf_posts posts   left outer join wp_g6exrf_postmeta meta on meta.post_id = posts.id  ! ( posts.post_status = 'auto-draft' )   order posts.id, meta.meta_key, meta.meta_value 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -