I have a variable which contains a full name and a table which has the names separated into first name and last name.
I am trying to update records where the first name joined with the last name equals the variable.
$row[1]="Joe Bloggs"
$sql = "UPDATE staff SET deductions='$row[15]', $phonepayment = '$row[16]' WHERE firstname.' '.lastaname= $row[1]";
How would I go about achieving this?
You should use CONCAT :
UPDATE staff
SET deductions='$row[15]', $phonepayment = '$row[16]'
WHERE CONCAT(firstname, ' ', lastaname) = $row[1]
Try with the below query,you can combine strings using + operator.
$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]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.