Hey everyone!

With the holiday season upon us, we want to share our upcoming working hours:

After that, we’ll return to our regular schedule and assist you as quickly as possible.

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find tons of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel), which might just have the answers you need while we’re away.

Thanks a bunch for your understanding and support!

Warm regards and happy holidays!

TMS

Okay
  Public Ticket #2929258
Setting Variable for mySQL FROM Table
Closed

Comments

  • Bradley Thornhill started the conversation

    I have a Pie Chart that is using filtered data from a table. I have attached the code that I am using. I have a View created in MySQL and then a query on the site. I have attached both of them in one file for you to see.

    Is there a way that I can make this work?


  • [deleted] replied

    Hi Bradley

    Thank you for reaching out to us.

    You will need to create a view from the query in wpDataTables as well. 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, and search may not work properly if you include:

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

    Please prepre a MySQL view (which will return the data that you need, call it e.g. “view1” and then build a wpDataTables based on a simple query like "SELECT * FROM view1″.


  • Bradley Thornhill replied

    Thanks for the reply, but I stated that I do have a VIEW query created. I showed you what they were in the text file. However, you did not answer my question of how i can use a Variable in the FROM section of this query that I am trying to do.

  • [deleted] replied

    Hi Bradley

    My apologies if there was a misunderstanding, from the below quoted section I assumed this is the actual query you use when creating a wpDataTable and the queries are included in it

    This is the Query in WPDataTables
    SELECT 
        t3.label,
        SUM(t3.yes)/2,
        t3.procedureDate
    FROM 
    (SELECT 
        t1.label,
        t1.yes,
        t1.procedureDate
    FROM
        BBKidneyCalloutsAugmentedBacktableTraineeChart t1  
    JOIN
        BBKidneyCalloutsAugmentedBacktableDoctorChart t2  
    ON
        t1.traineeName = t2.traineeName
    WHERE
        t1.surgeryID = t2.surgeryID 
    AND 
        (t1.traineeName = "%VAR1%" AND t2.traineeName = "%VAR1%")) t3
    GROUP BY t3.label
    

    As I mentioned below we have some limitations when it comes to certain statement types so it the above query is what you would use to create the table you would have issues in displaying the content.

    However if you created a query that falls under what our plugin can handle and you are having these issues we will have to ask you for a set of admin login credentials to the website where this happens so we can have a look from the inside, as it is usually the fastest way to resolve issues.