MySQL Forums
Forum List  »  PHP

Re: Search Query
Posted by: Rick James
Date: August 31, 2010 08:48AM

That can be simplified to

(SELECT * FROM tablename1)
UNION ALL
(SELECT * FROM tablename2)
ORDER BY columnname;

The tables do not have to be identical, but the number of fields in the SELECT need to be the same:

(SELECT a, b FROM tablename1)
UNION ALL
(SELECT xxx, yyy FROM tablename2)
UNION ALL
(SELECT 12, 'abcdef' FROM tablename2)
ORDER BY columnname;

The datatypes ought to be the same.

Options: ReplyQuote


Subject
Written By
Posted
August 30, 2010 06:31PM
August 31, 2010 12:43AM
August 31, 2010 06:10AM
Re: Search Query
August 31, 2010 08:48AM
August 31, 2010 10:45AM
August 31, 2010 10:52AM
August 31, 2010 07:32PM
September 01, 2010 11:11AM
September 01, 2010 11:35AM
September 01, 2010 12:40PM
September 01, 2010 02:14PM
September 01, 2010 02:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.