Table Source "SQL Query" with mysql variables not working

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #21639

    hallo301107
    Participant

    Hi,

    I generate a table by SQL query and am using mysql variables in this query (like @variable). This is NOT working, although it is working perfectly, if I run the query directly in my database (PHPMyAdmin).

    This is the MySQL query:

    SELECT
    @distanz := sum( if( g.field_id = 7, g.value, ”) ) AS “Gesamt-KM”,
    case when @distanz > 45 then ‘geschafft’ else ‘offen’ end AS “Meilenstein 1”,
    case when @distanz > 100 then ‘geschafft’ else ‘offen’ end AS “Meilenstein 2”,
    case when @distanz > 200 then ‘geschafft’ else ‘offen’ end AS “Meilenstein 3”
    FROM
    wp_wpforms_entry_fields g
    WHERE
    form_id = 5738

    You can see it on the following page: https://crowdlauf.de/tabletestldzmz/ (1st table)
    The “Gesamt-KM” is “51” so it is greater than “45” so it should display “geschafft” and not “offen”.

    Perhaps there are problems interpreting variables with “@” in your plugin?

    Thanks for help and greetings from Germany.

    Robert

    #21645

    hallo301107
    Participant

    Erm, still waiting for an answer from you!

    This NOT working within your plugin, but sql statement does work, if directly called in phpMyAdmin (so statement is valid):

    SELECT
    @distanz := sum( if( g.field_id = 7, g.value, ”) ) AS “Gesamt-KM”,
    case when @distanz > 45 then ‘geschafft’ else ‘offen’ end AS “Meilenstein 1”,
    case when @distanz > 100 then ‘geschafft’ else ‘offen’ end AS “Meilenstein 2”,
    case when @distanz > 200 then ‘geschafft’ else ‘offen’ end AS “Meilenstein 3”
    FROM
    wp_wpforms_entry_fields g
    WHERE
    form_id = 5738

    By the way, this is the scheme of the base table on which the above query is applied:

    -------------------------------------
    entry_id | form_id | field_id | value
    -------------------------------------
    13       | 5738    | 3        | Robert
    13       | 5738    | 6        | 13
    13       | 5738    | 7        | 11
    14       | 5738    | 3        | Daniel
    14       | 5738    | 6        | 34
    14       | 5738    | 7        | 21

    etc.

    I would appreciate an answer shortly.

    #21652

    hallo301107
    Participant

    Wordpress – 5.1.1

    #21654

    Ole_Support
    Keymaster

    Hi, @hallo301107
    Thank you for contacting us regarding your question.
    Please contact us through our 
    internal support.
    We will help you to solve the problem.

    Best regards,
    https://supsystic.com
    Ole

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Thanks so much! Please Enter Your Info Below To Get PRO Discount and Gifts