我的iPhone应用程序遇到了问题 - 我用sqlite3创建了两个表:
create table A (Name varchar(50), Added datetime);
create table B (UserID varchar(50), Username varchar(50), Created datetime);
我需要按时间顺序获取两个表的所有值,如:
Alen 2011-06-25 17:56:00
12 Fire 2011-06-26 17:56:00
Bale 2011-07-01 17:56:00
如你所见,表格之间没有任何关系,我对此一无所知。
该应用正在进行中,很难重新设计数据库。 我想知道基于当前数据库架构的解决方案(这也是老板的要求)。
答案 0 :(得分:4)
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