主页 > 知识库 > 数据库 > SQL server >

sql--仅用来测试blog

来源: 作者: 发表于:2012-08-21 14:14  点击:
Sql代码 create table people( id int , sex varchar(20), class int ); create table class( id int , classno varchar(20) ); insert into people value(1,g,1), (2,b,2), (3,g,3); insert into class value (1,one class), (2,two class); select * from

Sql代码 
create table people( 
  id int , 
  sex varchar(20), 
  class int 
); 
create table class( 
  id int , 
  classno varchar(20) 
); 
 
insert into people value(1,'g',1), 
                        (2,'b',2), 
                        (3,'g',3); 
insert into class value (1,'one class'), 
                        (2,'two class'); 
select * from people; 
select * from class; 
 
select * from people p,class c where p.class=c.id; 
select * from people p left join  class c on p.class=c.id; 
select * from people p right join  class c on p.class=c.id; 
select * from people p cross join class c; 

    有帮助
    (0)
    0%
    没帮助
    (0)
    0%