当我有select关键字时,找不到选择关键字错误

时间:2017-02-10 00:26:19

标签: sql database oracle

 (select course_id
 from section
 where semester = 'FALL' AND  year = 2009)
  intersect all 
 (select course_id
 from section
 where semester = 'SPRING' AND  YEAR = 2010);

我正在阅读Henry Korth的数据库系统概念。我正在尝试完全按照书中的方式进行交集,但是当我有select关键字时,我会错过选择关键字错误。

编辑:看起来我只是在使用'交叉全部'但是'相交'工作正常时才会出错

1 个答案:

答案 0 :(得分:2)

ALLINTERSECT部分Oracle部分未使用ALL部分。 UNIONINTERSECT一起使用,MINUSselect course_id from section where semester = 'FALL' AND year = 2009 intersect select course_id from section where semester = 'SPRING' AND YEAR = 2010; 。尝试没有......(也没有必要的括号,他们不会伤害任何东西,只是不需要):

PostgreSQL

显然ALL支持INTERSECT Oracle,但with intersect_tbl as ( select course_id, row_number(partition by course_id) as rnum from section where semester = 'FALL' AND year = 2009 intersect select course_id, row_number(partition by course_id) as rnum from section where semester = 'SPRING' AND YEAR = 2010 ) select course_id from intersect_tbl; 不支持INTERSECT ALL。我确实看到了使用以下方法可以模仿的地方:

PostgreSQL

既然你提到你发现你的例子的书是由你的学校指定的,我会告诉他们你是否应该为你的班级使用特定的DBMS。正如我在Oracle中提到的那样[a[i - 1], a[j]] = [a[j], a[i - 1]];可用,因此他们可能希望您使用该风格而不是function shuffle(a) { for (let i = a.length; i; i--) { let j = Math.floor(Math.random() * i); [a[i - 1], a[j]] = [a[j], a[i - 1]]; } }

相关问题