SQL语句,查询

来源:互联网 发布:mac 实用工具 编辑:程序博客网 时间:2024/05/16 11:02

 

↘多对多

select c.* from course c, (select sc.* from sc,(select * from student where name='liu') s where s.id=sc.id_student) sc where c.id=sc.id_course;


 

 

↘查找ID为18的blog 的所以评论。1条 查 多条

select * from (    select * from blog where id=18        ) b,comment c where b.blog_id=b.id;或者是 select c.* from comment as c where c.blog_id=18;

 

↘查询ID为18的blog的分类。 1条 查 1条

select c.* from (    select * from blog where id=18        ) b,category c where b.category_id=c.id;

 

↘分页查询

select * from (    select my_table.*, rownum  my_rownum from (        select name, birthday from employee order by birthday            ) my_table where rownum < 120                 ) where my_rownum >= 100;

 

 

@@@