SQL-如果存在,则将更新插入其他
我想要做的就是INSERT在我的数据库的用户,但IF EXISTS它应该UPDATE排,ELSE INSERT INTO一个新行。 Ofcourse我连接到数据库第一和GET的$name,$email并$birthday从URL字符串。 $con=mysqli_connect("localhost","---","---","---"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $name=$_GET['name']; $email=$_GET['email']; $birthday=$_GET['birthday']; 可以,但是只添加新行; mysqli_query($con,"INSERT INTO subs (subs_name, subs_email, subs_birthday) VALUES ('$name', '$email', '$birthday')"); mysqli_close($con); 这是我尝试过的; mysqli_query($con,"INSERT INTO subs (subs_name, subs_email, subs_birthday) VALUES '$name', '$email', '$birthday' ON DUPLICATE …