• Resolved sdmeijer

    (@sdmeijer)


    This is my query:

    SELECT
    p.ID,p.post_title,p.post_content,
    (SELECT group_concat(wp_terms.name separator ', ')
        FROM wp_terms
        INNER JOIN wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id
        INNER JOIN wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
        WHERE taxonomy= 'category' and p.ID = wpr.object_id
    ) AS "Categories",
    CONCAT('http://www.festivalvantalent.nl/algemeen/aanbieders/', p.post_name) as post_name,p.post_status,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'organisatie'
    order by m1.meta_id DESC
    LIMIT 0,1) as organisatie,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'contactpersoon'
    order by m1.meta_id DESC
    LIMIT 0,1) as contactpersoon,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'e-mailadres'
    order by m1.meta_id DESC
    LIMIT 0,1) as emailadres,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'aanmelden'
    order by m1.meta_id DESC
    LIMIT 0,1) as aanmelden,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'lokaal'
    order by m1.meta_id DESC
    LIMIT 0,1) as lokaal,
     p.post_date, p.post_modified
    FROM wp_posts AS p
    LEFT OUTER JOIN wp_term_relationships r ON r.object_id = p.ID
    LEFT OUTER JOIN wp_term_taxonomy x ON x.term_taxonomy_id = r.term_taxonomy_id
    LEFT OUTER JOIN wp_terms t ON t.term_id = x.term_id
    WHERE p.post_type = 'post'
    and p.post_status = 'publish'
    and t.slug = 'aanbieders'

    But when viewing the report is doesn’t have a result, because it changes my LIMIT 0,1) to LIMIT 0,25 1). (I also tried LIMIT 1, but that doesn’t help.)
    Can this be resolved?

    https://wordpress.org/plugins/exports-and-reports/

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

    (@sc0ttkclark)

    In cases like this where you’ve got a complicated subquery, I built a solution to the problem.

    To the main query, add LIMIT %%LIMIT%% and the plugin will explicitly use that for the query interaction instead.

    Thread Starter sdmeijer

    (@sdmeijer)

    Thank you!
    Where exactly do I have to put LIMIT %%LIMIT%% in my query?

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Add it to the end of your main query, so at the very end 🙂

    Thread Starter sdmeijer

    (@sdmeijer)

    Thank you, but unfortunately it doesn’t work.

    When debugging I get this:

    SELECT SQL_CALC_FOUND_ROWS p.ID,p.post_title,p.post_content, (SELECT group_concat(wp_terms.name separator ', ') FROM wp_terms INNER JOIN wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id INNER JOIN wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id WHERE taxonomy= 'category' and p.ID = wpr.object_id ) AS "Categories", CONCAT('http://www.festivalvantalent.nl/algemeen/aanbieders/', p.post_name) as post_name,p.post_status, (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'organisatie' order by m1.meta_id DESC LIMIT 0,1) as organisatie, (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'contactpersoon' order by m1.meta_id DESC LIMIT 0,1) as contactpersoon, (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'e-mailadres' order by m1.meta_id DESC LIMIT 0,1) as emailadres, (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'aanmelden' order by m1.meta_id DESC LIMIT 0,1) as aanmelden, (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'lokaal' order by m1.meta_id DESC LIMIT 0,1) as lokaal, p.post_date, p.post_modified FROM wp_posts AS p LEFT OUTER JOIN wp_term_relationships r ON r.object_id = p.ID LEFT OUTER JOIN wp_term_taxonomy x ON x.term_taxonomy_id = r.term_taxonomy_id LEFT OUTER JOIN wp_terms t ON t.term_id = x.term_id WHERE p.post_type = 'post' and p.post_status = 'publish' and t.slug = 'aanbieders' LIMIT 0,25

    This is my query:

    SELECT
    p.ID,p.post_title,p.post_content,
    (SELECT group_concat(wp_terms.name separator ', ')
        FROM wp_terms
        INNER JOIN wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id
        INNER JOIN wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
        WHERE taxonomy= 'category' and p.ID = wpr.object_id
    ) AS "Categories",
    CONCAT('http://www.festivalvantalent.nl/algemeen/aanbieders/', p.post_name) as post_name,p.post_status,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'organisatie'
    order by m1.meta_id DESC
    LIMIT 0,1) as organisatie,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'contactpersoon'
    order by m1.meta_id DESC
    LIMIT 0,1) as contactpersoon,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'e-mailadres'
    order by m1.meta_id DESC
    LIMIT 0,1) as emailadres,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'aanmelden'
    order by m1.meta_id DESC
    LIMIT 0,1) as aanmelden,
    (select m1.meta_value from wp_postmeta as m1 where m1.post_id = p.ID AND m1.meta_key = 'lokaal'
    order by m1.meta_id DESC
    LIMIT 0,1) as lokaal,
     p.post_date, p.post_modified
    FROM wp_posts AS p
    LEFT OUTER JOIN wp_term_relationships r ON r.object_id = p.ID
    LEFT OUTER JOIN wp_term_taxonomy x ON x.term_taxonomy_id = r.term_taxonomy_id
    LEFT OUTER JOIN wp_terms t ON t.term_id = x.term_id
    WHERE p.post_type = 'post'
    and p.post_status = 'publish'
    and t.slug = 'aanbieders'
    LIMIT %%LIMIT%%
    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Are you seeing any MySQL / DB errors with your query?

    Thread Starter sdmeijer

    (@sdmeijer)

    Oops, sorry.

    Forgot I removed all posts from this website, because it’s a website for a yearly event and we’re starting blank each year.

    It doesn’t give any results, because there aren’t any posts. 😉

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Oops 🙂

    Have a great year, feel free to open new topics if you have any further problems!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Problem with LIMIT’ is closed to new replies.