• Resolved rizerapi

    (@rizerapi)


    Hi,

    Part of mysql qeury:

    WHERE        (Select meta_value From wp_postmeta wppo Where meta_key = '_billing_email' And wppo.post_id = wpp.post_id) LIKE '%@%'
    AND                       (Select post_date From wp_posts Where wp_posts.Id = wpp.post_id) >= '2021-02-01'
    AND                       (Select post_date From wp_posts Where wp_posts.Id = wpp.post_id) <= '2021-04-15'
    

    How to put %%where%% variable and use it to filter by date beetween?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    You can put your %%WHERE%% at the very end of your WHERE statement, so after all of your other conditions.

    rizerapii

    (@rizerapii)

    So, what is next? I add %%WHERE%% in the end.

    
    WP_PS.id) >= '2021-04-01' %%WHERE%%
    AND       (Select post_date FROM wp_posts WP_PS WHERE 
     WP_PS.Id = WP_WC.order_id GROUP BY WP_PS.id) <= '2021-04-30' %%WHERE%%
    

    or

    
    %%WHERE%% WP_PS.id) >= '2021-04-01' 
    AND       (Select post_date FROM wp_posts WP_PS WHERE %%WHERE%%
     WP_PS.Id = WP_WC.order_id GROUP BY WP_PS.id) <= '2021-04-30'
    

    How can use this variable in reports? Can I add my value for example ‘2020-01-01’ – first variable, ‘2021-01-01’ – second variable??

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    At the very end of your WHERE clause.

    So:

    
    WP_PS.id) >= '2021-04-01'
    AND       (Select post_date FROM wp_posts WP_PS WHERE 
     WP_PS.Id = WP_WC.order_id GROUP BY WP_PS.id) <= '2021-04-30'
    %%WHERE%%
    
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to use filtr date in my sql query?’ is closed to new replies.