Okay
  Public Ticket #3028275
MYSQL query issues
Closed

Comments

  • Alex started the conversation

    Hello I am attempting to create a data table by the option "generate a query to the mysql database" I select the 3 variables of interest and the GUI tool generates the query: 

    SELECT beta5.`temperaturemin`,
           beta5.`temperature`,
           beta5.`temperaturemax`
    FROM beta5

    I then manually add the condition:

    SELECT beta5.`temperaturemin`,
           beta5.`temperature`,
           beta5.`temperaturemax`
    FROM beta5 ORDER BY id DESC LIMIT 25

    but I get an error message, there shouldn't be anything wrong with this query, is it incompatible with WPDataTables?

  •  1,851
    Miloš replied

    Hi, Alex

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -

    In some situations, using certain functions within SQL, the wpDataTables server has problems with parsing the query and building new queries dynamically (rarely happens, but does sometimes).

    Our logic is based on a PHP SQL parser which has full support for the SQL dialect for the following statement types

    SELECT, INSERT, UPDATE, DELETE, REPLACE, RENAME, SHOW, SET, DROP, CREATE INDEX, CREATE TABLE, EXPLAIN and DESCRIBE.

    Some of them are disabled for security reasons.

    Filtering, sorting, calculation functions and search may not work properly if you include:

    Accent graves ( ` ) around the table name JOIN functions UNION functions CONCAT functions sub-queries -

    • Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden.
    • Please do not use “ORDER BY” in the SELECT statement. wpDataTables has its own sorting engine so it makes no sense to use MySQL’s sorting, since it will be overridden. Also, server-side processing feature adds this part of statement automatically when users trigger the sorting on the front-end, and having it in initial statement may cause the table to crash.

    -

    Perhaps you could try this modification:

    Remove the accent graves from the query ` ;

    and because you are setting the "FROM table_name", i would try like this :

    SELECT temperaturemin,
           temperature,
           temperaturemax
    FROM beta5

    Let me know if that helped, please. Thank you

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables