Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2003
    Posts
    6

    Unanswered: Help with SQL Update Query

    I have two tables, returnparts and dataimport. I am trying to update the ReviewNumber in the dataimport table with the reviewnumber in the returnparts table. Here is my query...

    UPDATE DataImport
    SET dataimport.ReviewNumber = returnparts.ReviewNumber
    From returnparts r, dataimport d
    where d.Customer = r.Customer and
    d.[Review Date] = r.ReviewDate and
    d.[Ref #] = r.referencenumber and
    d.disposition = r.Disposition and
    d.[Vehicle ID Number] = r.VIN and
    d.[Model Year] = r.ModelYear and
    d.[repair order #] = r.repairordernumber and
    d.[repair date] = r.repairorderdate and
    d.engine = r.engine and
    d.model = r.model and
    d.mileage = r.mileage and
    d.[customer comments] = r.customercomments

    Here is the error message I receive when I run this query.

    Server: Msg 107, Level 16, State 3, Line 1
    The column prefix 'returnparts' does not match with a table name or alias name used in the query.

    I thought I had the syntax correct but apparently I don't. Any help would be appreciated.

  2. #2
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Help with SQL Update Query

    UPDATE DataImport
    SET dataimport.ReviewNumber =
    (Select Top 1 returnparts.ReviewNumber
    From returnparts r, dataimport d
    where d.Customer = r.Customer and
    d.[Review Date] = r.ReviewDate and
    d.[Ref #] = r.referencenumber and
    d.disposition = r.Disposition and
    d.[Vehicle ID Number] = r.VIN and
    d.[Model Year] = r.ModelYear and
    d.[repair order #] = r.repairordernumber and
    d.[repair date] = r.repairorderdate and
    d.engine = r.engine and
    d.model = r.model and
    d.mileage = r.mileage and
    d.[customer comments] = r.customercomments)

  3. #3
    Join Date
    Jul 2003
    Posts
    6
    I tried this and I am recieving the same error message.

  4. #4
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    oups


    UPDATE DataImport
    SET ReviewNumber =
    (Select Top 1 r.ReviewNumber
    From returnparts r, dataimport d
    where d.Customer = r.Customer and
    d.[Review Date] = r.ReviewDate and
    d.[Ref #] = r.referencenumber and
    d.disposition = r.Disposition and
    d.[Vehicle ID Number] = r.VIN and
    d.[Model Year] = r.ModelYear and
    d.[repair order #] = r.repairordernumber and
    d.[repair date] = r.repairorderdate and
    d.engine = r.engine and
    d.model = r.model and
    d.mileage = r.mileage and
    d.[customer comments] = r.customercomments)

  5. #5
    Join Date
    Jul 2003
    Posts
    6
    This worked,,,,thanks so much for your help.

  6. #6
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    remember that you can only use one table
    in a update query

    but you can use a select statment
    that returns ONE Value
    (that's why I've added the top 1)

  7. #7
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Hmmm...I don't think it's an accurate statement, Karolyn...

    UPDATE d
    SET ReviewNumber = r.ReviewNumber
    From returnparts r, dataimport d
    where d.Customer = r.Customer and
    d.[Review Date] = r.ReviewDate and
    d.[Ref #] = r.referencenumber and
    d.disposition = r.Disposition and
    d.[Vehicle ID Number] = r.VIN and
    d.[Model Year] = r.ModelYear and
    d.[repair order #] = r.repairordernumber and
    d.[repair date] = r.repairorderdate and
    d.engine = r.engine and
    d.model = r.model and
    d.mileage = r.mileage and
    d.[customer comments] = r.customercomments

  8. #8
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    je vais mettre mon bonnet d'βne
    et m'agenouiller dans le coin


    SORRY !

    that's why I'm don' want all those stars
    makes a false impression.............;

  9. #9
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    ...translates as:

    I will put my donkey cap and to kneel me in the corner.

  10. #10
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    at school in the old days
    bad students
    had to put the donkey hat

  11. #11
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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