Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    5

    Question Unanswered: Update On Mulitple Records

    I Have three tables

    TASK
    taskid, taskname, projectid, workid
    1,,1,1
    2,,1,2
    3,,2,3

    PROJECT
    projectid, projectname
    1, project1
    2, project2
    3, project3

    WORK
    workid, workname
    1,work1
    2,work2
    3,work3

    I need to do an update this way

    Update the taskname as 'projectname' + '_' + 'workname' for any projectid.
    projectname and workname coming from the projectid and workid in the task record

    so the task table becomes
    1,project1_work1,1,1
    2,project1_work2,1,2
    3,project2_work3,2,3

    I can get all the records doing this

    SELECT p.projectname+ ' ' + w.workname AS 'NEWNAME'
    FROM task t
    JOIN work w
    ON t.workid = w.workid
    JOIN project p
    ON t.projectid = p.projectid
    WHERE projectid = 2

    how do i do an UPDATE?

    any help is appreciated

  2. #2
    Join Date
    Dec 2002
    Posts
    1,245
    I THINK that this is what you are looking for:

    Code:
    UPDATE TASK
    SET taskname = PROJECT.ProjectName + '_' + WORK.WorkName
    FROM
      TASK JOIN WORK ON
         TASK.WorkID = WORK.WorkID
      JOIN PROJECT ON
         TASK.ProjectID = PROJECT.ProjectID
    Regards,
    hmscott

  3. #3
    Join Date
    Feb 2004
    Posts
    5
    thanks hmscott,
    will give it a try

    reg
    db_montreal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •