Database

MySQL ON DUPLICATE KEY UPDATE

컨텐츠 정보

본문

$result = mysqli_query($con, "insert into goods (name, price, distance, department, count)
  values ('$name','$price','$distance', '$department', '1')ON DUPLICATE KEY UPDATE count=count+1");

    $checkValue = mysqli_affected_rows();
    if($checkValue==0) echo 'None Insert/Update';
    if($checkValue==1) echo 'Insert';
    if($checkValue==2) echo 'Update';

관련자료

댓글 0
등록된 댓글이 없습니다.
Today's proverb
Youth is not a time of life, but it is a state of mind. (사무엘울만)