SQL更新数据库中的记录 [英] SQL to update records in database
问题描述
嗨
我在数据库表中有超过900条记录,其中一个字段例如名为TM_LOC,其中包含位置路径和位于该位置的项目。
所以通常位置看起来像这样
D:\CHANNEL_FIVE \ BROADCAST \已完成
然后,当物品被放入该位置时,我们正常使用的系统将存储该物品的位置,例如:
D:\CHANNEL_FIVE \ BROADCAST \COMPLETED \ EHD0152368
因此EHD0152368是该文件的名称在位置上。
但是,它不会出现D:\CHANNEL_FIVE \ BROADCAST \COMPLETEDEHD0152368删除路径位置和项目本身之间的\。
在PLSQL中,我想编写一个SQL,以便能够更新已获得此位置且位置和路径之间没有\的所有数据。
我希望有人可以帮我解决这个问题的新手,所以任何帮助都会非常感激。
如果您需要更多信息,请告诉我
谢谢
尝试:
UPDATE MyTable SET TM_LOC = SUBSTRING(TM_LOC, 0 , 36 )+ ' \' + SUBSTRING(TM_LOC, 36 , 10000 )
WHERE TM_LOC NOT LIKE ' D:\CHANNEL_FIVE \ BROADCAST \COMPLETED \%'
Hi
I have over 900 records in a database table which one of the fields for example called TM_LOC which contains location path and the item that is on the location.
So normally the location would look like this
D:\CHANNEL_FIVE\BROADCAST\COMPLETED
Then when at items has been put into the location the system that we using normally would store the location against that item for example:
D:\CHANNEL_FIVE\BROADCAST\COMPLETED\EHD0152368
So the EHD0152368 is the name of the file that is on the location.
However, its not coming out as D:\CHANNEL_FIVE\BROADCAST\COMPLETEDEHD0152368 removing the \ between the path location and the item itself.
In PLSQL i want to write an SQL to be able to update all the data that has got this location and that has no \ between the location and the path.
I hope someone could help me out with the sql i m very new to this, so any help would be much appreciated.
Let me know if you need more information
Thanks
Try:
UPDATE MyTable SET TM_LOC=SUBSTRING(TM_LOC, 0, 36) + '\' + SUBSTRING(TM_LOC, 36, 10000) WHERE TM_LOC NOT LIKE 'D:\CHANNEL_FIVE\BROADCAST\COMPLETED\%'
这篇关于SQL更新数据库中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!