我有一个变量,其中包含一个全名和一个名称分为名和姓的表。连接两列在哪里
我想更新记录的名字加上姓氏等于变量。
$row[1]="Joe Bloggs"
$sql = "UPDATE staff SET deductions='$row[15]', $phonepayment = '$row[16]' WHERE firstname.' '.lastaname= $row[1]";
我该如何去做到这一点?
我有一个变量,其中包含一个全名和一个名称分为名和姓的表。连接两列在哪里
我想更新记录的名字加上姓氏等于变量。
$row[1]="Joe Bloggs"
$sql = "UPDATE staff SET deductions='$row[15]', $phonepayment = '$row[16]' WHERE firstname.' '.lastaname= $row[1]";
我该如何去做到这一点?
你应该使用CONCAT:
UPDATE staff
SET deductions='$row[15]', $phonepayment = '$row[16]'
WHERE CONCAT(firstname, ' ', lastaname) = $row[1]
尝试用下面的查询,您可以使用+操作符组合的字符串。
$row[1]="Joe Bloggs"
$sql = "UPDATE staff
SET deductions='$row[15]', $phonepayment = '$row[16]'
WHERE firstname+' '+lastaname= $row[1]";
使用此您的WHERE子句中:
WHERE firstname + ' ' + lastname = $row[1]
WHERE姓名+”“+ lastaname = $行[1]“;串联在SQL中使用+,不 –
你试图做什么 – Dmytrechko
更新记录时出错:您的SQL语法错误;请查看与您的MySQL服务器版本相对应的手册,以找到在'= '38 .86'附近使用的正确语法WHERE firstname +''+ lastname = Alis Rose'在第二行 – MattBlack