请教SQLITE如何删除表内重复的记录
答案:1 悬赏:70
解决时间 2021-01-30 09:01
- 提问者网友:空白
- 2021-01-30 01:14
请教SQLITE如何删除表内重复的记录
最佳答案
- 二级知识专家网友:不傲怎称霸
- 2021-01-30 02:22
$ sqlite3
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table tb_test (id int, val char(32));
sqlite> insert into tb_test values (1, 'adb');
sqlite> insert into tb_test values (2, 'def');
sqlite> insert into tb_test values (2, 'ghi');
sqlite> insert into tb_test values (1, 'jkl');
sqlite> insert into tb_test values (3, 'mnu');
sqlite> select * from tb_test;
1|adb
2|def
2|ghi
1|jkl
3|mnu
sqlite> select * from tb_test a
...> where not exists (select 1
...> from tb_test b
...> where b.id = a.id
...> and a.rowid > b.rowid)
...> ;
1|adb
2|def
3|mnu
sqlite> .q
$
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table tb_test (id int, val char(32));
sqlite> insert into tb_test values (1, 'adb');
sqlite> insert into tb_test values (2, 'def');
sqlite> insert into tb_test values (2, 'ghi');
sqlite> insert into tb_test values (1, 'jkl');
sqlite> insert into tb_test values (3, 'mnu');
sqlite> select * from tb_test;
1|adb
2|def
2|ghi
1|jkl
3|mnu
sqlite> select * from tb_test a
...> where not exists (select 1
...> from tb_test b
...> where b.id = a.id
...> and a.rowid > b.rowid)
...> ;
1|adb
2|def
3|mnu
sqlite> .q
$
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯
• 手机登qq时,显示手机磁盘不足,清理后重新登 |
• 刺客的套装怎么选啊? |