简体   繁体   中英

update multiple rows with same id

I have two tables employeedetails and educationdetails

employeedetails

empid   name 
  1      xyz
  2      asd
  3      pqr

Now this empid is a foreign key in educationdetails

empid   qualification  Percentage
1          SSC             56
1          HSC             78
1          BE              55
2          SSC             80
2          HSC             67
2          BE              71

I want to update second table educationdetails like for empid 1 i want to change the marks of HSC from 78 to 80

how to do this as we are having 3 rows with same id

First define PRIMARY KEY to table educationdetails .

Use below query.

UPDATE educationdetails 
SET Percentage = 80 
WHERE empid=1 AND qualification = 'HSC' 

You have to uniquely identify the column you want to update in the educationdetails table. So you will need to know the empid and the qualification of the row you want to amend.

UPDATE educationdetails 
  SET Percentage = 80 
WHERE empid=1 AND qualification = 'HSC' 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM