Solved

update fields from one field to another

Posted on 2010-11-30
3
270 Views
Last Modified: 2012-05-10
Hi
I have one table (Items) with the following details
Itemcode, ItemDescription, lastmaintdate

another table Maintenance
MaintReqID, MaintitemCode, MaintDate

I have to for one item multiple maintenance request in table maintenance I need to write a query to update lastmaintdate in table items with the recent date of the maintenance table of the same item.

can you help me with this
0
Comment
Question by:nadermik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 34237117
update items
set lastmaintdate = (select max(maintdate) from maintenancem m
where m.maintitemcode=items.itemcode)
0
 
LVL 9

Expert Comment

by:s_chilkury
ID: 34237167
update [items]
set lastmaintdate =
(
      select top 1 maintdate from [maintenance]
      where items.itemcode = maintenance.maintitemcode
      and [whatever clause you need more]
      order by maintdate desc
)
0
 
LVL 23

Expert Comment

by:Rajkumar Gs
ID: 34237206
update i
set lastmaintdate = (select max(MaintDate) from  Maintenance where MaintitemCode = i.Itemcode)
from items i
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question