I met a problem in my iPhone App - I create tow tables with sqlite3:
create table A (Name varchar(50), Added datetime);
create table B (UserID varchar(50), Username varchar(50), Created datetime);
I need to get all the values of the two tables ordered by time, which is like:
Alen 2011-06-25 17:56:00
12 Fire 2011-06-26 17:56:00
Bale 2011-07-01 17:56:00
As you see there is no relationship between of the tables, I've no idea about it.
The app is undergoing, and it's difficult to redesign the DB. I'd like to know the solution based on the current DB schema (this is also the boss's requirement).
SELECT NULL AS Col1, Name AS Col2, Added AS Col3
FROM A
UNION ALL
SELECT UserID AS Col1, Username AS Col2, Created AS Col3
FROM B
ORDER BY 3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.