Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#4154 (ok 4.1.1) Error using UNION query

4.0.9
fixed
Marc Delisle
None
1
2015-01-16
2013-11-15
DisgruntledGoat
No

On a table view, click a column to order by that column. Then execute a UNION query with that table and another one (with the ordered table coming second).

An error comes back: #1054 - Unknown column 'sortunion2.id' in 'order clause'

Here is a sample table definition:

CREATE TABLE IF NOT EXISTS `sortunion1` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `sortunion1` (`id`, `name`) VALUES
(1, 'aaa'),
(2, 'bbb');

CREATE TABLE IF NOT EXISTS `sortunion2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;

INSERT INTO `sortunion2` (`id`, `name`) VALUES
(1, 'vvv'),
(2, 'xxx'),
(3, 'yyy'),
(4, 'zzz');

Sort by the id on sortunion2, then run this:

SELECT * FROM `sortunion1`
UNION
SELECT * FROM `sortunion2`

Discussion

  • I am also unable to find a way to remove the table sorting. It seems like without that the query would work.

    Edit: realised that table sorting is stored in the phpmyadmin meta tables, so I can find the appropriate row and remove it. Would be much better to have a way to clear that on the table view though.

     
    Last edit: DisgruntledGoat 2013-11-18
  • As a temporary workaround you can disable remembering table's sort order. To do this, go to Settings -> Main Panel -> Browse Mode -> untick Remember table's sorting

     
  • Lakshit Arora
    Lakshit Arora
    2013-12-07

    Hello, I am new to this community. I am trying my hands on this bug.

     
  • Marc Delisle
    Marc Delisle
    2013-12-08

    • assigned_to: Marc Delisle
     
  • Marc Delisle
    Marc Delisle
    2013-12-08

    • summary: Error using UNION query --> (ok 4.1.1) Error using UNION query
    • status: open --> resolved
    • Priority: 5 --> 1
     
  • Marc Delisle
    Marc Delisle
    2013-12-17

    • Status: resolved --> fixed