|
|
Sponsor |
Re: [Fwd: Result of UNION depends on order of fields in SELECT]: msg#00019db.mysql.bugs
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
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: MySQL 4.1.0 dies on Subselect in Select-Expression, Sinisa Milivojevic |
|---|---|
| Next by Date: | Re: [Fwd: Result of UNION depends on order of fields in SELECT], Vincenzo Ciaschini |
| Previous by Thread: | [Fwd: Result of UNION depends on order of fields in SELECT], Vincenzo Ciaschini |
| Next by Thread: | Re: [Fwd: Result of UNION depends on order of fields in SELECT], Vincenzo Ciaschini |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive 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 |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|