logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

Re: [Fwd: Result of UNION depends on order of fields in SELECT]: msg#00019

db.mysql.bugs

Subject: Re: [Fwd: Result of UNION depends on order of fields in SELECT]

Vincenzo Ciaschini writes:
> consider the following database:
> CREATE TABLE t (
> val1 int(11) default NULL,
> vl2 int(11) default NULL
> ) TYPE=MyISAM;
>
> --
> -- Dumping data for table 't'
> --
>
> INSERT INTO t VALUES (1,2);
> INSERT INTO t VALUES (3,4);
>
> Now execute this query:
> select val1, vl2 from t where val1=3 union select val1, vl2 from t where
> val1=1;
>
> The result is:
>
> +------+------+
> | val1 | vl2 |
> +------+------+
> | 3 | 4 |
> | 1 | 2 |
> +------+------+
> 2 rows in set (0.00 sec)
>
> Correct
>
> Now execute this query:
>
> select val1, vl2 from t where val1=3 union select vl2, val1 from t where
> val1=1;
>
> The result is:
>
> +------+------+
> | val1 | vl2 |
> +------+------+
> | 3 | 4 |
> | 2 | 1 |
> +------+------+
> 2 rows in set (0.00 sec)
>
> Wrong.
>
> Shouldn't the union statement reorder the fields in the second select?
>
> Bye,
> Vincenzo

Hi!

No, union should not reorder columns.

Why would it be done ???

You will always get the columns in the order you asked.

--

Sincerely,

--
For technical support contracts, go to https://order.mysql.com/?ref=msmi
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Mr. Sinisa Milivojevic <sinisa@xxxxxxxxx>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB
/_/ /_/\_, /___/\___\_\___/ Fulltime Developer and Support Coordinator
<___/ www.mysql.com Larnaca, Cyprus


--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@xxxxxxxxxxx







Only community members can participate in forum threads. You must Register or log in to contribute.

<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo