Okay
  Public Ticket #2563034
Table filtering not working
Closed

Comments

  •  1
    Adam Gogo started the conversation

    Hello,

    I have created a table from SQL and the table filtering is not working.  The only thing unique about it is the SQL that has been created has subqueries in the SELECT clause.

    Here is a copy of the SQL for your review:

    select
    concat(a.application_first_name, " ", a.application_last_name) Applicant_Name,
    a.application_current_city,
    a.application_household_type,
    a.application_birthdate,
    a.application_age,
    (select count(*) from household where household_age < 19 and application_id = a.application_id) children_count,
    (select count(*) from household where household_age < 5 and application_id = a.application_id) children_under_5,
    (select count(*) from household where household_age < 19 and upper(household_gender) like '%M%' and application_id = a.application_id) male_children,
    (select count(*) from household where household_age < 19 and upper(household_gender) like '%F%' and application_id = a.application_id) female_children,
    (select count(*) from household where application_id = a.application_id) + 1 household_members
    from application a
    where upper(application_housed) = 'NO'


    Please advise,

    ~Adam

  •  2,572
    Aleksandar replied

    Hello Adam

    You have a complicated query, so wpDataTables server has problems parsing this query. Such queries (with joins, unions, concats, subqueries) cannot be properly filtered, sorted or searched through.

    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