I recommend using a select to find out if there are such parameters previously registered, being as follows:
SELECT count(desc) as 'qtdDesc' FROM table WHERE desc = 'descAserInserida' AND grau = 'grauAserInserido';
Then just check if 'qtdDesc' > 0, then do not register, otherwise you register.
how do I use this when entering data into the table?
Use as follows, example with mysqli
$conn = new mysqli ("localhost", "USUARIO", "SENHA", "nome_DB");
$result = $conn->query("SELECT count(descricao) as 'qtdDesc' FROM table WHERE descricao = '$descAserInserida' AND grau = '$grauAserInserido'");
$row = $result->fetch_row();
if ($row[0] > 0) {
//existe, não insere
echo "existe";
} else {
echo "não existe";
$sql = "INSERT INTO table (descricao,grau) VALUES('$descAserInserida','$grauAserInserido')";
$result = mysqli_query($conn,$sql);
}
$conn->close();
No, I don’t understand. The third example is
: adcde
which is different from the first two– user60252
Know what a primary key originated from two or more columns?
– Costamilam
@Leocaracciolo kk vc ta right, I wrote wrong corrected ja
– Eduardo Rodrigues
@Guilhermecostamilam I don’t know, how it works?
– Eduardo Rodrigues
But do you want to check if there is already a record in the table according to your examples? Easier than taking candy from the hand of a child in the bakery!
– user60252