Tagged: mysql-query variables bug
- This topic has 3 replies, 2 voices, and was last updated 3 years, 12 months ago by
Ole_Support.
- AuthorPosts
- March 28, 2019 at 13:26 #21639
hallo301107ParticipantHi,
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 = 5738You 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
April 1, 2019 at 22:00 #21645
hallo301107ParticipantErm, 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.
April 1, 2019 at 23:08 #21652
hallo301107ParticipantWordpress – 5.1.1
April 3, 2019 at 11:09 #21654
Ole_SupportKeymasterHi, @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 - AuthorPosts
- You must be logged in to reply to this topic.