开发者

SQLite date sorting problem

开发者 https://www.devze.com 2023-02-05 17:27 出处:网络
I am having 2 tables: Table1: ID,Type,form_date Table2: ID, Type, form_date Now, i want to fetch uniq date list (type wise) from both the tables and

I am having 2 tables:

Table1: ID,Type,form_date

Table2: ID, Type, form_date

Now, i want to fetch uniq date list (type wise) from both the tables and stores into the third table. How do i do such?

Date example:

Table-1:

Type    form_date
1       20/12/2010
1       25/04/2010
2       05/11/2010

Table-2:

Type form_date
1    20/12/2010
2    25/04/2010
2    05/11/2010

I want to have output as below:

Table-3 or Output

Type form_date
1    20/12/2010
1    25/04/2010
2    25/04/2010
2    05/11/2010

Please suggest me a possible solution. Thanx

Update:

Thanx a lot dan04. From @dan04 answer, i am having success to store Type, form_date from both the tables.

But when i try to execute below query to get only form_date values then it is giving me an error:

SELECT form_date FROM Table1
UNION SELECT form_date FROM Table2

please suggest me how do i have only form_date from both the tables开发者_JS百科?


SELECT Type, form_date FROM Table1
UNION SELECT Type, form_date FROM Table2

Also, store your dates in YYYY-MM-DD order so they'll sort correctly.

0

精彩评论

暂无评论...
验证码 换一张
取 消