• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

SQL Query to Compare and then UPDATE

Hi, I am new to SQL, and would like some help please.

I am trying to compare 2 tables only 1 column in those tables. The tables are

1.) dbo.ImportPCMCost
2.) dbo.ImportIncludedList

The 2 tables are:

1.) dbo.ImportPCMCost.Procedure_Code_ID
2.) dbo.ImportIncludedCost.ID

I want to match these 2 Colums and then I want to UPDATE the FEE Column that is located in dbo.ImportIncludedCost table. Please
0
dmanisit
Asked:
dmanisit
1 Solution
 
LowfatspreadCommented:
update dbo.importincludedcost
  set fee =?
 from dbo.importincludedcost as c
 inner join dbo.importpcmcost as p
 on c.id=p.procedure_code_id
0
 
rushShahCommented:
try this,


update c
set c.fee = CASE WHEN c.ID=p.Procedure_Code_ID THEN '?' ELSE '?' END
from dbo.importincludedcost as c, dbo.importpcmcost as p

Open in new window

0
 
SharathData EngineerCommented:
UPDATE c 
   SET fee = p.fee -- or any hard coded value 
  FROM dbo.importincludedcost AS c 
       INNER JOIN dbo.importpcmcost AS p 
         ON c.id = p.procedure_code_id

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
dmanisitAuthor Commented:
So I have the Fee in the table ImportPCMCost named Fee that I want to take this Fee and update ImportIncludedList Table Field name Fee also
0
 
SharathData EngineerCommented:
Then try the last statement posted.
0
 
dmanisitAuthor Commented:
Thats awesome, thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now