Okay
  Public Ticket #2641654
Filtering is not working
Closed

Comments

  • Andreas Lazaris started the conversation

    Hello

    I have a table based on an SQL query. Although, data are presented fine, there is no option of filtering, which does not produce any results.

    Here follows the SQL query:

    SELECT 
          hospital as 'Hospital_name',
          COUNT(*)        
              as 'Aortic Aneurysm Disease',
          (          
          SELECT COUNT(*)        
              FROM registry_aortic_aneurysm_disease 
              WHERE hospital = Hospital_name AND date_of_treatment >= '2020-01-01 00:00:00' 
              AND date_of_treatment < '2021-01-01 00:00:00'
              AND (location='Infrarenal' OR location='Iliac')
              ) as 'Infrarenal',

    (          
          SELECT COUNT(*)        
              FROM registry_aortic_aneurysm_disease 
              WHERE hospital = Hospital_name AND date_of_treatment >= '2020-01-01 00:00:00' 
              AND date_of_treatment < '2021-01-01 00:00:00'
              AND (location='Infrarenal' OR location='Iliac')
              AND clinical_condition='Asymptomatic'
              ) as 'Infrarenal Asymptomatic',

    (          
          SELECT COUNT(*)        
              FROM registry_aortic_aneurysm_disease 
              WHERE hospital = Hospital_name AND date_of_treatment >= '2020-01-01 00:00:00' 
              AND date_of_treatment < '2021-01-01 00:00:00'
              AND (location='Infrarenal' OR location='Iliac')
              AND clinical_condition!='Asymptomatic'
              ) as 'Infrarenal Symptomatic (incl Ruptured)',

          (          
          SELECT COUNT(*)        
              FROM registry_aortic_aneurysm_disease 
              WHERE hospital = Hospital_name AND date_of_treatment >= '2020-01-01 00:00:00' 
              AND date_of_treatment < '2021-01-01 00:00:00'
              AND location!='Infrarenal'
              ) as 'Not infrarenal' 

    FROM registry_aortic_aneurysm_disease WHERE date_of_treatment >= '2020-01-01 00:00:00' AND date_of_treatment < '2021-01-01 00:00:00'
    GROUP BY Hospital_name

    Any help would be much appreciated.

    Kind regards, and a Happy New Year

    Andreas


  •  2,513
    Aleksandar replied

    Hello Andreas

    Thank you for your purchase.

    The issue here is with the PHP SQL parser we use. While the query is showing data correctly, it won't allow tables with JOINs, UNIONs, CONCATs, subqueries, etc. to be filtered or sorted.

    To avoid this please prepare a MySQL view (a stored query), which will return the data that you need, call it e.g. “view1” and then build a wpDataTabled based on a simple query like “SELECT * FROM view1″.

    Please note some this when working with the server-side processing feature:

    • 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.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    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