Discussion Locked

SQL

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

It may seem simple, but I need it badly.

How can I get records of two tables in order (with SQL). I can join tables together, but can't do this. Example:

Table1
----------------------
| Bill_Date | Remark |
----------------------
| 01.02.03 | tab1_1 |
| 03.02.03 | tab1_2 |
----------------------

Table2
----------------------
| Bill_Date | Remark |
----------------------
| 02.02.03 | tab2_1 |
| 04.02.03 | tab2_2 |
----------------------

After joining
----------------------
| Bill_Date | Remark |
----------------------
| 01.02.03 | tab1_1 |
| 02.02.03 | tab2_1 |
| 03.02.03 | tab1_2 |
| 04.02.03 | tab2_2 |
----------------------

records must be ordered by soe criteria, for example date.

Thanks alot in advance!

7 replies

by phdj2000

Have you tried using the order by clause>

Select Blah blah blah join blah blah blah Order by Bill_Date, Remark

by john_wills

SELECT Bill_Date,Remark
FROM
(SELECT Bill_Date,Remark from Table1
UNION
SELECT Bill_Date,Remark from Table2)
ORDER BY Bill_Date,Remark;
This is what the previous contributor suggested, but it occurred to me that you might not know the syntax of UNION.

This discussion is closed to new replies.