Okay
  Public Ticket #1597908
Creating more than one column in wpdatatables
Closed

Comments

  • Frank started the conversation

    I am having trouble figuring out how to add columns to a table.

    an example is:

    SELECT lx_usermeta.meta_key, lx_usermeta.meta_value FROM lx_usermeta WHERE meta_key = "wpcf-dc-license-number" OR meta_key = "wpcf-dc-license-expiration" OR meta_key = "wpcf-maryland-license-number" or meta_key = "first_name" or meta_key = "last_name"

    but this will show all the meta_key results for each wordpress database field in the same column

    I have considered you cannot add columns and that each table must be simple. I decided to try and create individual tables for each meta_value, like a table for "wpcf-dc-license-number" and "wpcf-dc-license-expiration" as two separate tables, thinking I could maybe then create a manual table and select foreign keys as the data for each column.

    My ultimate question is, can I add columns to my tables and create the sql logic they draw data from for each one? If not, can I create separate tables like I tried, and then manually create a table built with foreign keys?


    I can see that SELECT lx_usermeta.meta_key, lx_usermeta.meta_value creates a column for both lx_usermeta.meta_key and lx_usermeta.meta_value, so I get that your plugin is capable of multiple columns.

  •  471
    Isidora replied

    HI Frank,
    Thank you for your purchase.

    WordPress and its plugins store the data in a specific MySQL database, usually referred to as “WPDB”. The structure familiar to users, is based on different post types, post custom (meta) fields, and taxonomies; all stored in a collection of MySQL tables. Querying these elements, however might be somewhat of a headache to someone not that familiar with relative database structures and building SQL queries.

    wpDataTables has a built-in WPDB query constructor to help those users. It has a graphical user interface which allows a user to pick the post types, custom/meta fields, and taxonomies, and generates a query and a preview. You can modify the query as needed, and create a wpDataTable based on the modified query.

    You can read more about this on this link.

    Please note that this tool is not an ultimate query generator, it just constructs a suggestion of a query. We constantly work on improving it, but SQL is such a complicated and flexible language that full automation for constructing queries is hardly possible. So the more complicated the query is, the higher is the chance that it will not return exactly what you need.


    Kind Regards, 

    Isidora Markovic

    wpDataTables: FAQFacebookTwitterFront-end and back-end demoDocs

    Amelia: FAQFacebookTwitter |  Amelia demo sites | Docs

    You can try our wpDataTables add-ons before purchase on these sandbox sites:

    Powerful FiltersGravity Forms Integration for wpDataTablesFormidable Forms Integration for wpDataTables