Okay
  Public Ticket #1509701
Correlated Sub-queries
Closed

Comments

  •  2
    cdtadmin started the conversation

    It looks like wpdatatables does not allow correlated sub-queries. It this something that will be available eventually, or can we at least have an option to "allow query if you know what your doing"?   

    This works great in MySQL, but wpdatatables is throwing up an error. Here is the query:

    SELECT count(*) AS TOTAL_SPONSORS,
    (SELECT count(*) FROM table1 as p WHERE NOT EXISTS (SELECT t.sponsor_slug FROM table2 as t where t.sponsor_slug = p.sponsor_slug)) AS EMPTY_TABLES,
    (SELECT count(*) FROM table1 as p WHERE EXISTS (SELECT t.sponsor_slug FROM table2 as t where t.sponsor_slug = p.sponsor_slug)) AS FILLED_TABLES
    FROM table1

    The error is:
    unknown [expr_type] = reserved in “WHERE” [1]

    This query is valid and work fine in MySQL from the command line or via phpMyAdmin.
    Thanks for considering adding this feature!

  • [deleted] replied

    Hi Cdtadmin,

    We will take a look at this and consider implementing solution for the problem. In the meantime I suggest you to create MySQL VIEW from this query and use that as a tables source. It should solve the problem.  

  •  2
    cdtadmin replied

    What a most excellent idea!  Thanks!

  •  2
    Paul replied

    I know from the title of this ticket my error is not a correlated Sub-queries but i have gotten the same error in the post. Views to help with the problem but simple functions shouldn't be limited to items like these.  

    I get the same error "unknown [expr_type] = reserved" when looking at a data value between or even greater than a data value.

    SOME_DATE BETWEEN NOW() - INTERVAL 90 DAY AND NOW()

    SOME_DATE >= DATE(NOW()) - INTERVAL 90 DAY

  • [deleted] replied

    Hi purcepa,

    If you have problem that it is not related to the ticket please open a new one in future.

    For your suggestion please understand that this problem is more complex than it may seems. We could implement solution which will preview data in the tables but create a quality solution which will support all plugin functionality like sort or advanced filtering could grew in complexity real quickly. We are working on improving plugin features and functionalities so please stay tuned for updates