简体   繁体   English

更新具有相同ID的多行

[英]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 我想更新第二张表的教育详细信息,如Empid 1,我想将HSC的分数从78更改为80

how to do this as we are having 3 rows with same id 如何执行此操作,因为我们有3个具有相同ID的行

First define PRIMARY KEY to table educationdetails . 首先定义“主键”以列出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. 您必须在educationdetails表中唯一标识要更新的列。 So you will need to know the empid and the qualification of the row you want to amend. 因此,您将需要知道要修改的行的具体empidqualification

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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