The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

A Mysql GOD in the neighborhood ? (4 posts)

  1. Pixelboss
    Posted 9 years ago #

    Hi everyone,

    I absolutely need to add a separate table in my MYsql database, calling for each post.

    I can't explain here but custom fields won't work for what I need.

    So I will hack the WP core (I have no choice in fact and emergency is so important for the project... I will see for update problems later) to make new fields in the admin panel.

    I have one but big question : how do I must write queries to call my new data(s) from my new table for a specific post ?

    I have tried LEFT JOIN but it doesn't work.

    In fact I think my new table structure isn't good. I have created a separate table called "moredates" and inside I have created 3 fields : "frozendate", "startdate", "enddate"...with a DATETIME configuration.

    But Mysql says to me there isn't a "key" to my table, and how make clear the link between these new dates and each post ??? My query doesn't know to witch post belongs the new dates in the table ?

    Is there a Mysql GOD in the neighborhood ?! Please help. I have made the functions to manage the dates (except the good queries) and the fields in the admin panel. I have only a big Mysql problem (where I am not good at all)...

  2. Chris_K
    Posted 9 years ago #

    You don't have a MySQL problem. You have a SQL issue. :-)

    For starters:
    In your "moredates" table, add a column for Post_ID. That will match the ID column from the wp_posts table and give you a way to relate/join the two tables. It will also be your key.

  3. Pixelboss
    Posted 9 years ago #


    Thanks for your answer !

    I have create in my table a column "post_id" with a "BIGINT(20)" configuration (like in the "wp_post2cat" table).

    After I have define this column as the key for the table "moredates", so I have now :

    Key name : PRIMARY
    Type : PRIMARY
    Cardinalité :0
    Field : post_id

    I don't know why a key is needed but I have made one to avoid the big red line of warnings. :-x

    Do you think I'm good for the Mysql structure ? If you say me yes I will work on my functions and stop search bugs inside my new table...

    Thanks again for the help anyway !

  4. Chris_K
    Posted 9 years ago #

    Well, you're playing with a relational database... you want a key if you want to be doing any relating. ;-)

    Without knowing more about what you're doing (and I don't want to!) you seem to be on the right track now with your table structure.

Topic Closed

This topic has been closed to new replies.

About this Topic