CREATE TABLE ta(
id INTEGER PRIMARY KEY,
aa VARCHAR(2) not null,
bb VARCHAR(8) not null,
cc INTEGER not null,
dd INTEGER not null
);
CREATE TABLE tb(
id INTEGER PRIMARY KEY,
aa VARCHAR(2) not null,
bb VARCHAR(8) not null,
cc INTEGER not null,
ee INTEGER not null
);
drop table ta;
insert into ta values(null, '1', '2', 1, 1);
insert into ta values(null, '3', '2', 3, 3);
insert into ta values(null, '5', '2', 5, 5);
insert into ta values(null, '7', '2', 7, 7);
insert into ta values(null, '9', '2', 9, 9);
insert into ta values(null, '11', '2', 11, 11);
insert into ta values(null, '13', '2', 13, 13);
insert into ta values(null, '15', '2', 15, 15);
insert into tb values(null, '2', '2', 2, 2);
insert into tb values(null, '4', '2', 4, 4);
insert into tb values(null, '6', '2', 6, 6);
insert into tb values(null, '8', '2', 8, 8);
insert into tb values(null, '10', '2', 10, 10);
insert into tb values(null, '12', '2', 12, 12);
insert into tb values(null, '14', '2', 14, 14);
insert into tb values(null, '16', '2', 16, 16);
SELECT * FROM ta,tb where ta.bb=tb.bb;
//join
SELECT ta.aa,tb.aa FROM ta inner join tb where ta.id=tb.id ;
// union
SELECT aa,bb,cc FROM tb union select aa,bb,cc from ta order by (cc) desc limit 1 offset 0;
select * from ta;
select * from tb;
SQLITE的实践笔记(1)
最新推荐文章于 2024-04-23 10:54:24 发布