left join测试验证之一

$ sqlite3 a.db
SQLite version 3.8.1 2013-10-17 12:57:35
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table a (uname char(10),uid int);
sqlite> create table b (uid int, udepart int);
sqlite> create table c (uid int, ustate int);
sqlite> insert into a values('U1',1);
sqlite> insert into a values('U2',2);
sqlite> insert into a values('U3',3);
sqlite> insert into b values (1,1);
sqlite> insert into b values (2,2);
sqlite> insert into c values (1,1);
sqlite> insert into c values (2,2);
sqlite> select a.uname,a.uid,b.udepart,c.ustate from a left join b on a.uid = b.uid left join c on a.uid=c.uid;
U1|1|1|1
U2|2|2|2
U3|3||
sqlite> select a.*,b.udepart,c.ustate from a left join b on a.uid = b.uid left join c on a.uid=c.uid;
U1|1|1|1
U2|2|2|2
U3|3||
sqlite> .header on
sqlite> select a.*,b.udepart,c.ustate from a left join b on a.uid = b.uid left join c on a.uid=c.uid;
uname|uid|udepart|ustate
U1|1|1|1
U2|2|2|2
U3|3||
sqlite> insert into a values('u4',4);
sqlite> insert into c values(4,4);
sqlite> select a.*,b.udepart,c.ustate from a left join b on a.uid = b.uid left join c on a.uid=c.uid;
uname|uid|udepart|ustate
U1|1|1|1
U2|2|2|2
U3|3||
u4|4||4
sqlite>

你可能感兴趣的:(left join)