SELECT p.stud_id,p.name,s.course_id,s.grade
FROM stud_info p,stud_grade s
WHERE p.stud_id>s.stud_id
这是书上的SQL语句,运行没有记录,不懂,求解释。

解决方案 »

  1.   

    有没有内容取决于表中的数据。declare @table1 table (id int,col varchar(1))
    insert into @table1
    select 1,'a' union all
    select 2,'b' union all
    select 3,'c'
    declare @table2 table (id int,col varchar(1))
    insert into @table2
    select 2,'d' union all
    select 3,'e' union all
    select 4,'f'select * from @table1 a,@table2 b where a.id>b.id
    /*
    id          col  id          col
    ----------- ---- ----------- ----
    3           c    2           d
    */
      

  2.   

    哈哈,叶子,你的SQL语句我看得懂了。这种比较到底有什么作用呢,能举个例子么?
      

  3.   

    嗯,其实这SQL语句的意思大概能知道什么意思,但是不知道到底有什么作用。
      

  4.   

    需要与现有数据作比较stud_info--stud_id 最小值 
    >
    stud_grade--stud_id 最大值 (查看一下此表是否没有记录)