You are not logged in.
Pages: 1
Hi, sorry for my bad english.
I have a question for Mysql and ORDER BY function.
I have 2 tables (TabA and TabB for example). In a TabA there is a column DateA with unix time data. In a TabB there is a column DateB with unix time data.
For example:
TabA
+------+---------+
| xxxA | DateA |
+------+---------+
| abc | 123 |
+------+---------+
| asd | 126 |
+------+---------+
| rsgf | 127 |
+------+---------+
TabB
+-------+---------+
| xxxB | DateB |
+-------+---------+
| try | 124 |
+-------+---------+
I would like to merge TabA and TabB and order the row by unix time. For example:
+------+-------+---------+----------+
| xxxA | xxxB | DateA | DateB |
+------+-------+---------+----------+
| abc | | 123 | |
+------+-------+---------+----------+
| | try | | 124 |
+------+-------+---------+----------+
| asd | | 126 | |
+------+-------+---------+----------+
| rsgf | | 127 | |
+------+-------+---------+----------+
Thanks.
Offline
SELECT * FROM tabA, tabB
ORDER BY tabA.dateA, tabB.dateB DESC
with merging i think you want to put all the tabs togheter without a particular condition, so you just simply cross them togheter
Offline
SELECT * FROM tabA, tabB
ORDER BY tabA.dateA, tabB.dateB DESC
This will order them by dateA first and then by dateB, I think he wants them sorted on the union of the dates.
Offline
I think he wants them sorted on the union of the dates.
yes....
Offline
select bla from bla
union
select bla from bla2
order by bla
ᶘ ᵒᴥᵒᶅ
Offline
select bla from bla union select bla from bla2 order by bla
But the 2 columns have different name....
Offline
But the 2 columns have different name....
that's not a problem, each column you define in the select will be added to the result. you can combine columns to a single result but you don't have to:
ᶘ ᵒᴥᵒᶅ
Offline
monotiz wrote:But the 2 columns have different name....
that's not a problem, each column you define in the select will be added to the result. you can combine columns to a single result but you don't have to:
Ok thanks.. I try it...
Offline
since columns have different name but the same type, i think you can merge them into one only column and then order that one
Offline
That would be a full (outer) join on the two timestamp columns, and after that order by the merged colums. But I'm not really sure about mysql capabilities...
If everything else fails, read the manual.
Offline
Pages: 1