我有files
表
(userID, fileID, fileName, folderID, folderName).
我想为找到重复项的用户更新多行,例如
目前,我userID=1
2 files
folderName
'work'
和folderID of '1'
下的'work1'
我想将folderName更新为folderID of '1'
,但保持相同UPDATE files SET fileFolder = '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID'
。
这是我当前的sql语句,我无法让它工作:
{{1}}
答案 0 :(得分:0)
UPDATE files SET fileFolder = '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID'
而不是设置fileFolder,你尝试使用folderName吗?比如..
UPDATE files SET folderName= '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID'
答案 1 :(得分:0)
如果工作文件夹有多次,你需要更新文件夹名称,例如work to work1。所以你需要检查旧文件夹是否有多次。
尝试这样的事情(未经测试):
UPDATE files SET folderName= '$folderName'
WHERE folderID = '$folderID' AND userID = '$userID' AND ( 1 < (SELECT count(*) from files where folderID = $folderID and folderName='oldFolderName'))