Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple question

Status
Not open for further replies.

seahorse123

Programmer
Jul 25, 2005
39
0
0
US
I have two tables: tb1, tb2
"tb1" contains fields:
user,
project,
lastupdate

"tb2" contains fields:
user,
profile,
address

"tb1": each user may have multiple projects, with different update time.

Now I want to join this two tables to list all users with profile, address and the latest project update time.

How to write SELECT statement? thanks.
 
Try this:
Code:
select    a.user, 
          a.profile, 
          a.address, 
          b.lastupdate
from      Table2 a,
          (select   user, 
                    max(lastupdate) lastupdate
           from     Table1
           group by user) b
where     a.user = b.user

Regards,
AA
 
I'm hoping that user is really userid? If this contains names you could be introuble becasue two people can have the same name and then they would not join correctly.

Questions about posting. See faq183-874
Click here to learn Ways to help with Tsunami Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top