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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nested select and update

Status
Not open for further replies.

bluebytez

Programmer
Joined
Dec 20, 2001
Messages
39
Location
MY
Hi, I have a problem with a database which I have imported from a text file.
In one of my tables, there are more a few rows for each staff. The problem is, the data for one of the columns ( i.e. Age ) only exists in the first row of the same staff. How do I make a SQL statement to fill the other rows belonging to the same staff with the data from the first row ?
I hope I have not confused anyone.
Thanks for your help !
 
If I understand your question.

update staff1 set age = staff2.age
from staff staff1, staff staff2 where
staff1.staffid = staff2.staffid and
staff1.age is null and staff2.age is not null

if the missing data is not null replace the null check with whatever would be appropriate for the missing data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top