Posted by mrclash on 10/06/06 12:26
Hello,
I have a Database in a SQL Server 2000 where I have different users
tables with equal fields like this:
id (int)
email (varchar)
name (varchar)
address (varchar)
joinedon (datetime)
I want to merge all the tables in one taking rows with the same email
but taking always the more recent fields based on the 'joinedon' field.
So if I have this four different rows:
Tbl email name address joinedon
--------------------------------------------------------------------------------------------
T1 j@smith.com johnathan NULL 01/01/95
T2 j@smith.com NULL barcelona street 01/01/98
T3 j@smith.com john valencia street 01/01/97
T4 j@smith.com john Q NULL 01/01/99
And the final row entered in the new table would be
Tbl email name address joinedon
----------------------------------------------------------------------------------------
new j@smith.com john Q barcelona street 01/01/99
I am trying doing his with union statements, but i am not getting the
real merging of data. Any clue?
Thanks for your help.
Navigation:
[Reply to this message]
|