Update with join tables

  • Hi,

    I have the following statement

    UPDATE tbl_service_models

    set tbl_service_models.Maintenance_Standard_KM=20000

    JOIN tbl_family on

    tbl_service_models.car_family_id=tbl_family.car_family_id

    where tbl_family.brand_code=6 and tbl_service_models.Maintenance_Standard_KM=15000

    and I get error:

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'JOIN'.

    Can anyone please help?

    Regards,

    John

  • j.grimanis (7/31/2009)


    Hi,

    I have the following statement

    UPDATE tbl_service_models

    set tbl_service_models.Maintenance_Standard_KM=20000

    JOIN tbl_family on

    tbl_service_models.car_family_id=tbl_family.car_family_id

    where tbl_family.brand_code=6 and tbl_service_models.Maintenance_Standard_KM=15000

    and I get error:

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'JOIN'.

    Can anyone please help?

    Regards,

    John

    You need the from clause to be there and then join to that. See if this works:

    UPDATE tbl_service_models

    set tbl_service_models.Maintenance_Standard_KM=20000

    from tbl_service_models

    JOIN tbl_family on

    tbl_service_models.car_family_id=tbl_family.car_family_id

    where tbl_family.brand_code=6 and tbl_service_models.Maintenance_Standard_KM=15000

  • Great! Thanks.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply