Mysql
 sql >> Database >  >> RDS >> Mysql

Distinguere tra UPDATE non riuscito a causa di condizioni false e UPDATE non riuscito a causa di valori invariati

Prima di tutto, se i valori sono gli stessi, MySQL non aggiornerà la riga, quindi il conteggio delle righe interessate sarà 0.

Soluzione per questo problema :

$query="SELECT count(*) as cnt FROM `songs` WHERE `music_name`='$name', `price`='$price' AND `genre`=$genre" ;
/****get count from the query******/
if(count > 0 ) {
//update the table row
}
else{
//insert the table row
}