Okay
  Public Ticket #3049310
sql based table
Closed

Comments

  • Bartosz Lorenc started the conversation

    Hi.
    I have a problem with JOIN, INNER JOIN based on two tables as below
    I was trying to JOIN them with no result actually (got mysql errors)and after few hours i give up
    I belive there must be a solution but i think now that i don't understant JOIN - INNER JOIN but I don't know if You would like to help me in such problem.
    this is display only table.


    Table 1 - is created with:

        SELECT * FROM jawe_wpdatatable_8
        UNION ALL
        SELECT * FROM jawe_wpdatatable_9
        UNION ALL
        SELECT * FROM jawe_wpdatatable_9_1
        UNION ALL
        SELECT * FROM jawe_wpdatatable_9_2
        UNION ALL
        SELECT * FROM jawe_wpdatatable_9_3
        UNION ALL
        SELECT * FROM jawe_wpdatatable_9_4

    and works fine - it is dynamicly created from other tables whose data is changing
    It is created as sql query table, and look like this

    Table 1

    | uzytkownik  | other importand columns...  |
    |-------------|-----------------------------|
    | 2           | some data                   |
    | 1           | some data                   |
    | 2           | some data                   |
    | 2           | some data                   |
    | 2           | some data                   |

    table 2 - jawe_users:

    | ID  | user_nicename  | other not importand columns...|
    |-----|----------------|------------------------------|
    | 1   | bart           |                              |
    | 2   | asia           |                              |

    the result I expect should be like this:

    table 1 
    | uzytkownik | other importand columns... |
    |------------|----------------------------|
    | asia       | some data                  |
    | bart       | some data                  |
    | asia       | some data                  |
    | asia       | some data                  |
    | asia       | some data                  |

    I want to replace 2,1 and other ID numbers with coresponding with them user_nicename from jawe_users

    Tanks in advance for any help.

    Best regards.

  •  2,572
    Aleksandar replied

    Hello there.

    Thank you for your purchase.

    Using MySQL queries requires at least a basic knowledge of SQL. It is assumed that you can create the table in some MySQL data manager (e.g., PHPMyAdmin, MySQL Workbench), and prepare a SQL query that will return the data you need. If you do not know how to use MySQL, refer to the “Create a MySQL-query-based table by generating a query to MySQL database” section. It will explain how to create complete tables or MySQL queries without this basic knowledge.

    Please be advised that preparing MySQL queries for you is not included in the plugin support.

    Try altering the query by adding "UNION ALL" at the end of the query also. That often helps.

    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

    You can try preparing 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″.


    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