如何使用搜索和替换查询来更新SQLite数据库?

前端之家收集整理的这篇文章主要介绍了如何使用搜索和替换查询来更新SQLite数据库?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的sql知识非常有限,特别是关于sqlite,虽然我相信这将是某种通用查询…或者也许不是因为搜索和替换… @H_403_1@我在sqlite中有这个音乐数据库,当然这里有各种各样的字段,但重要的是“media_item_id”和“content_url”。

@H_403_1@以下是“content_url”的示例:

file:///c:/users/nazgulled/music/band%20albums/devildriver/%5b2003%5d%20devildriver/08%20-%20what%20does%20it%20take%20(to%20be%20a%20man).mp3
@H_403_1@我正在寻找一个查询,将搜索这样的条目,其中“content_url”遵循该模式,并用其他内容替换它(“content_url”)。

@H_403_1@例如,通用的“content_url”可以是:

file:///c:/users/nazgulled/music/band%20albums/BAND_NAME/ALBUM_NAME/SONG_NAME.mp3
@H_403_1@我想用以下替换所有这些条目:

file:///c:/users/nazgulled/music/bands/studio%20albums/BAND_NAME/ALBUM_NAME/SONG_NAME.mp3
@H_403_1@如何在一个查询中执行?

@H_403_1@P.S:我正在使用Firefox sqlite Manager(找不到更好,更自由的替代Windows)。

你可能正在寻找替换功能。 @H_403_1@例如,

update table_name set 
  content_url = replace(content_url,'band%20albums','bands/studio%20albums')
where
  content_url like '%nazgulled/music/band_20albums/%';
@H_403_1@更多文档http://sqlite.org/lang_corefunc.html

猜你在找的Sqlite相关文章