通过选择相同的表列值来更新表中的列值

时间:2021-08-14 19:18:17

I am trying to update download_count in my web app.i tried this way

我试图在我的网络app.i尝试更新download_count尝试这种方式

update  data_files  d set d.download_count=(select f.download_count from data_files f  where f.filename='file.txt')+1 where d.filename='file.txt'

but not update column value.Can this have alternative Solution

但不更新列值。可以使用替代解决方案

1 个解决方案

#1


0  

You can simplify this to:

您可以将其简化为:

update  data_files  d 
set d.download_count= d.download_count+1
where d.filename = 'file.txt'

#1


0  

You can simplify this to:

您可以将其简化为:

update  data_files  d 
set d.download_count= d.download_count+1
where d.filename = 'file.txt'