ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Error 1054: Unknown column '' in 'order clause'

June 20, 2013 5:58am

Subscribe [3]
  • #1 / Jun 20, 2013 5:58am

    gents agency

    16 posts

    I’m having this error when updating from 2.5.5 to 2.6.1 when going from the list of entries to the edit page in the backend.

    A Database Error Occurred
    Error Number: 1054
    
    Unknown column '' in 'order clause'
    
    SELECT DISTINCT `exp_channel_titles`.`entry_id`, `exp_channel_titles`.`title` FROM (`exp_channel_titles`) WHERE `exp_channel_titles`.`channel_id` IN (NULL) AND `exp_channel_titles`.`entry_date` <  371721836 AND (exp_channel_titles.expirati OR exp_channel_titles.expiration_date > 1371721836) AND `exp_channel_titles`.`entry_id` != '163' OR `exp_channel_titles`.`entry_id` IN ('62') ORDER BY `
    
    Filename: fieldtypes/relationship/ft.relationship.php
    
    Line Number: 359

    It’s not this one: https://support.ellislab.com/bugs/detail/19321. That bug was fixed in my current version of EE.

    Thanks in advance!
    Diederik.

  • #2 / Jul 22, 2014 7:46am

    Michael C. (KKCJ)

    100 posts

    I just encountered an extremely similar error to this, upgrading from 1.7.1 to 2.9:

    A Database Error Occurred
    Error Number: 1054
    
    Unknown column '' in 'order clause'
    
    SELECT DISTINCT `exp_channel_titles`.`entry_id`, `exp_channel_titles`.`title` FROM (`exp_channel_titles`) WHERE `exp_channel_titles`.`channel_id` IN (NULL) AND `exp_channel_titles`.`entry_date` <  406029029 AND (exp_channel_titles.expirati OR exp_channel_titles.expiration_date > 1406029029) ORDER BY `
    
    Filename: fieldtypes/relationship/ft.relationship.php
    
    Line Number: 435

    Did you ever figure this one out?

  • #3 / Jul 23, 2014 11:57am

    I ran into the exact same problem after a 1.7.3->2.9.0 upgrade. I seem to have solved it by hacking the ft.relationship.php file found in system/expressionengine/fieldtypes/relationship

    Around line 336, replace:

    ee()->db
          ->distinct()
          ->from('channel_titles')
          ->select('channel_titles.entry_id, channel_titles.title')
          ->order_by($order_field, $this->settings['order_dir']);

    with…

    if ($order_field != '')
          {
          ee()->db
                ->distinct()
                ->from('channel_titles')
                ->select('channel_titles.entry_id, channel_titles.title')
                ->order_by($order_field, $this->settings['order_dir']);
          }
    
    if ($order_field == '')
          {
          ee()->db
                ->distinct()
                ->from('channel_titles')
                ->select('channel_titles.entry_id, channel_titles.title');
          }

    This essentially excludes the ORDER BY from the query in the event that no order_field is specified.

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases