From: Dan Nelson Date: August 29 2002 5:12am Subject: Re: Join with Union List-Archive: http://lists.mysql.com/mysql/118322 Message-Id: <20020829051216.GC4308@dan.emsphone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii In the last episode (Aug 29), suresh said: > I dont really get your point Another thing I would like to highlight > I thought UNION will be used to join to SQL Queries and will display > only distinct values unless UNION ALL is used > > I don't know why the result is wierd or I do some misunderstanding > about UNION Here are the results of the query and UNION gives a > result that is very ubnormal > > Can anyone please explain why > > mysql> SELECT a.order_id, a.order_name FROM orderdetails AS a WHERE a.order_id = '001'; > +----------+-------------+ > | order_id | order_name | > +----------+-------------+ > | 001 | palanichamy | > +----------+-------------+ > 1 row in set (0.00 sec) > > mysql> SELECT c.order_id, c.nature FROM complaints AS c WHERE c.order_id = '001' ; > +----------+-----------------------+ > | order_id | nature | > +----------+-----------------------+ > | 001 | I cant read man | > | 001 | I cant install either | > +----------+-----------------------+ > 2 rows in set (0.00 sec) > > When union is used it gives the result > mysql> SELECT a.order_id, a.order_name FROM orderdetails AS a WHERE a.order_id = '001' > UNION ALL > SELECT c.order_id, c.nature FROM complaints AS c WHERE c.order_id = '001' ; > +----------+----------------------+ > | order_id | order_name | > +----------+----------------------+ > | 001 | palanichamy | > | 001 | I cant read man | > | 001 | I cant install eithe | > +----------+----------------------+ > 3 rows in set (0.00 sec) Apart from the missing 'r' in the last record, I don't see anything unusual. If that's what you're talking about, file a bug report with mysqlbug. -- Dan Nelson dnelson@stripped