设为首页 加入收藏

TOP

SQLite 3模糊查询简析
2014-11-24 03:13:20 来源: 作者: 【 】 浏览:3
Tags:SQLite 模糊 查询 简析
SQLite 3模糊查询简析
1. 创建 数据库 test.db
cd ~/
sqlite3 test.db
这样在 ~/ 目录下面就生成一个数据库文件 test.db.
2. 创建表 song www.2cto.com
create table if not exists song (path TEXT, title varchar(20));
创建一个名称为 song 的数据库表,包含 path、title 两个字段,
类型分别是 Text、varchar.
3. 插入数据
insert into song values('/mnt/sdcard/music','only you');
insert into song values('/mnt/sdcard/music','love');
insert into song values('/exte/music','thinking');
共插入 3 条数据。
这个时候,验证一下,数据库表中的数据。查询:
select * from song; www.2cto.com
4. 查询指定条件的数据
select * from song where path='/mnt/sdcard/music'
或者
select * from song where path="/mnt/sdcard/music"
现在有个需求,查出所有 / 目录下面的歌曲信息?
当然是模糊查询! www.2cto.com
select * from song where path LIKE '/%';
或者
select * from song where path LIKE "/%";
作者 AndroidBluetooth
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇MongoDB命令行操作 下一篇Cacti监控mysql数据库服务器实现..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C语言指针从入门到基 (2025-12-26 05:21:36)
·【C语言指针初阶】C (2025-12-26 05:21:33)
·C语言指针的定义和使 (2025-12-26 05:21:31)
·在 Redis 中如何查看 (2025-12-26 03:19:03)
·Redis在实际应用中, (2025-12-26 03:19:01)