Okay
  Public Ticket #2791781
Foreign keys
Closed

Comments

  • Daniel Lindley started the conversation

    I have a table which stores my data. This table also uses data as foreign keys from other tables. 

    I am trying to create a sql query to view all the data, not restricted by user. So that admin can see all records. I've followed tutorials etc and I'm struggling. 

    The data displays as the ID values from each of the tables. Each time I try and create sql relationships (inner or left joins) when I create more than one relationships it throws out an error. Usually that it can't place something. 

    I do want to create a different page with all records as well as another page heavily cut back all calling the same data. 


    Im sure this is possible and help would be appreciated. 


    Dan

  •  2,507
    Aleksandar replied

    Hello Daniel

    Thank you for your purchase.

    I don't quite understand the approach here, so if you could please provide me some screenshots, the query you're using, which column you're trying to use as a foreign key - with which table, etc. (as many details as possible), I'll gladly check it out, test it on my end (or on your website, if you wish to share your credentials with me), and see what's going on.

    If you're sharing sensitive info, please make sure to enable the PRIVATE response, since this is a public ticket.

    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

  • Daniel Lindley replied

    Hi Aleksandar;

    I figured out a work around. 

    To describe it better. I have a master table that also has select boxes that pulls data from sub-tables. Such as a table for "sex", "species" etc. 

    Initially I was using the primary key as a stored value and the text as a displayed value. I though this would make the relationship between the two table function better. However in the SQL query based on my master table was only showing the integer stored (primary key) from my sub tables. When i added my sub tables (about 6 sub tables) to the SQL query and tried to link the relationship in SQL query "wizard" it seemed to work fine for around 2 tables and did display the text rather than primary key... however more than 2 tables, the wizard threw out an error "no data" or "unable to find".

    I went back to the master table and used the text as the stored value. Now the SQL query shows the text which is what i needed. I also has a slight issue counting & grouping data from the SQL query (ie counting text items). I think I have fixed this by creating a hidden field, with a default value of 1 for each record. When i create a chart that seems to work fine now. 

    Thank you for your prompt response. Wpdatatables is taking some effort to learn but I'm hoping it will be exactly what our bat group needs. when its up and running, i would love it if its possible to "call" data as shortcode from the table/query and place this in a post. eg: "this year we had [wp_mytable_1.total] bat rescues"

    Once again, thanks for your assistance

    Dan

  •  2,507
    Aleksandar replied

    Hey Daniel, that's great news! Good workaround!

    The plugin is constantly developing, and although it may seem slow from time to time, I assure you that our developers are as busy as they can be. 

    I will forward the suggestion to them (at the moment, you can use the SUM shortcode of integer or float columns and display them on the front end), so they can add it to their "to-do" list.

    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