SQLITE的实践笔记(1)

              
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;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值