mysql - How can I LEFT JOIN Count in Subquery -


i have query, it's not throwing errors me & each subquery working expected when ran itself. when run whole thing, follows, columns: post_title & views

select post_title,         views,         coupons_today,         coupons_lifetime,         coupons_remaining    wp_posts p         left join wp_act ct --has views column               on ct . campaign_id = p . id         left join(select count(*)    coupons_today,                          campaign_id cid                     wp_act                    date = current_date) act1                on act1 . cid = p . id         left join(select count(*)    coupons_lifetime,                          campaign_id cid2                     wp_act) act2                on act2 . cid2 = p . id         left join(select count(*)    coupons_remaining,                          campaign_id cid3                     wp_ac                    status null) ac                on p . id = ac . cid3   p . post_status = 'publish' , p . post_type = 'page' , p . ping_status = 'open'; 

try way:

select  p.post_title,         ct.views,        ( select  count(*)              wp_act              date = current_date               ,  campaign_id = p.id        ) coupons_today,        ( select  count(*)              wp_act              campaign_id = p.id        ) coupons_lifetime,        ( select  count(*)              wp_ac              status null               ,  campaign_id = p.id        ) coupons_remaining      wp_posts p     left join  wp_act ct  on ct . campaign_id = p . id      p . post_status = 'publish'       ,  p . post_type = 'page'       ,  p . ping_status = 'open';  

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -