WordPress database error: [Not unique table/alias]

Home Forums Calendar Products Events Calendar PRO WordPress database error: [Not unique table/alias]

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #70572
    Michael
    Participant

    It seems the latest update nuked something.

    I add metaboxes to pages, posts and tribe_events. On the homepage, a WP_Query looks for a specific meta key/value, in order to display a few featured items.

    This has previously worked fine – after updating to 3.1, I’m getting the following error: WordPress database error: [Not unique table/alias: ‘cdc_postmeta’] (check out the site for more info, it’s a development install – I left the error up there)

    If I restrict the query to just posts and pages, everything works as expected. Help, please – I’m not even sure where I should start looking…

    #70804
    Chris
    Participant

    I think the error might tell you everything. Looks like either you’ve lost your postmeta table or you’ve managed to have two of them. Can you check to make sure you still have that table?

    -Chris

    #70836
    Michael
    Participant

    phpMyAdmin tells me there is one postmeta table, and the right meta key/value pairs are there. Nothing looks weird in the WordPress admin area, either: custom fields show as expected.

    Again: when I exclude tribe_events from the query, it works fine.

    #70839
    Chris
    Participant

    Are you on the latest version of all of the plugins running on your site?
    Check the error log for your server. It might be a bit more verbose about that error.

    #70840
    Michael
    Participant

    This reply is private.

    #70843
    Chris
    Participant

    Hmm, I’m wondering if the issue isn’t a failed database upgrade during the 3.1 update. Going to reassign to one of our other devs to have a look

    -Chris

    #71412
    Michael
    Participant

    Take your time…

    #71624
    Chris
    Participant

    Hi there,
    Okay so we took a look at the output, and I missed the really obvious thing here. There’s a table being joined in that query called “nrv_featured_item”. That’s not one of our tables, so its got to be coming from some sort of plugin or theme you’ve got installed.

    Can you try deactivating your plugins one by one. Likely your looking for a plugin with NRV or something that deals with Featured Items.

    -Chris

    #71637
    Michael
    Participant

    Yes, nrv_featured_item is the meta_key that allows items (Posts, Pages and Events) to be queried and thus featured on the homepage.

    Yes, that’s the problem, and if I turn it off, I don’t have a database error.

    As I stated a week ago, this worked fine before the upgrade to 3.1, and it does work fine when I exclude tribe_events from the query.

    The nrv_featured_item key/value pair shows in the Custom Fields box for the events in question, everything looks normal there, no PHP notices or warnings.

    Is there something you’ve changed in 3.1 with regards to how custom field keys/values are stored for the tribe_events post type? Would you like me to post up the code for the metaboxes and/or the WP_Query somewhere?

    I am using the WPAlchemy WordPress MetaBox PHP Class:
    https://github.com/farinspace/wpalchemy

    #71644
    Chris
    Participant

    We’re joining with postmeta by adding a meta_query arg to WP_Query. Probably ‘nrv_featured_item’ is being joined by adding SQL directly, and it’s not aliasing the table name. E.g., it’s doing “LEFT JOIN {$wpdb->postmeta} ON {$wpdb->postmeta}.meta_key=’nrv_featured_item'”, where it should be doing something like “LEFT JOIN {$wpdb->postmeta} nrv ON nrv.meta_key=’nrv_featured_item'”, giving a unique alias for the meta table for that join.

    -Chris

    #73969
    Chris
    Participant

    Hi there,
    Since we haven’t heard from you in a while, I’m going to close this ticket. If you need further help, feel free to open a new ticket 🙂

    -Chris

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘WordPress database error: [Not unique table/alias]’ is closed to new replies.