I have a files
table
(userID, fileID, fileName, folderID, folderName).
i want to update multiple rows for a user where duplicates are found such as
currently, I have userID=1
who has 2 files
both under the folderName
of 'work'
and folderID of '1'
,
i want to update the folderName to 'work1'
but keep the same folderID of '1'
.
this is my current sql statement and i can't get it to work:
UPDATE files SET fileFolder = '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID'
UPDATE files SET fileFolder = '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID'
instead of setting fileFolder, did you try using folderName ? such as ..
UPDATE files SET folderName= '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID'
you need to update folder name eg work to work1 if work folder has more than one time. so you need ti check if old folder has more than once.
Try something like this( not tested):
UPDATE files SET folderName= '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID' AND ( 1 < (SELECT count(*) from files where folderID = $folderID and folderName='oldFolderName'))
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.