Error updating a table. (Duplicate key)

Asked

Viewed 227 times

2

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

Good. When doing the update give me error.. Yes ja la I have a record in the table with those values, but when changing the type should not let me do?

  • What is the primary key?

1 answer

2


Yes I already have a record in the table with those values, but when changing the guy shouldn’t let me do?

No, what you have to do is use one Where , that is to say.

Update Falta_Licao
set Tipo = 1,
Descricao = ''
where Id_Turma = 1
and Id_Disciplina 1
and Licao = 1
and Id_Aluno = 3;

Practically your table has the two fields that you can change without having any problem, even without specifying the Where which are the Type and the Description, but if you try to update by changing the primary keys of your table it may be that you already have a record with the keys you are informing,.

Note that the primary key of your table is composed of 4 fields, if the combination of these fields already exists you will get this error.

If you need to update these fields the ideal is for you to have a single key for table, ie create a Id_falta_licao as a primary key, so you could change any field without problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.