• Resolved tiicaa

    (@tiicaa)


    How can I consult courses, purchases and coupons used by users? It is not possible to merge as two queries, it is possible to obtain data from the Sensei LMS through the wp_comments table, but it is not possible to show which products and which coupon was used by the users who purchased.

    SELECT wu.ID,
    wu.display_name,
    wm.comment_id,
    wm.meta_key,
    wm.meta_value,
    wc.*,
    woi.*
    
    FROM wp_posts wpo,  wp_users wu,
    wp_commentmeta wm 
    LEFT JOIN wp_comments wc ON wm.comment_id = wc.comment_ID
    AND wc.comment_type = 'sensei_lesson_status'
    LEFT JOIN wp_woocommerce_order_items woi ON woi.order_id = wc.comment_post_ID
    WHERE wu.ID = wc.user_id
    AND wpo.post_type = 'shop_order' OR wpo.post_type = 'shop_coupon'
    AND wc.comment_post_ID = wpo.ID
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘SQL query problems’ is closed to new replies.