SQL 查询帮助 - 使用 INTERBASE 的子查询
我有以下查询,
SELECT *
FROM
( select distinct
r1.rep_code,
r1.contact_id,
c1.Name,
e1.year_num,
e1.period_num
from
entry e1
join rep r1 ON e1.rep_code = r1.rep_code
join contact c1 on r1.contact_id = c1.contact_id
where
e1.entry_type = 'SJOB'
and e1.age = 0 )
我在第 3 行不断收到错误,
Token unknown - line 3, char 15
select
请您提供建议,顺便说一句,我正在使用 interbase IBConsole !
I have the following query
SELECT *
FROM
( select distinct
r1.rep_code,
r1.contact_id,
c1.Name,
e1.year_num,
e1.period_num
from
entry e1
join rep r1 ON e1.rep_code = r1.rep_code
join contact c1 on r1.contact_id = c1.contact_id
where
e1.entry_type = 'SJOB'
and e1.age = 0 )
I keep getting an error on line 3
Token unknown - line 3, char 15
select
can you please advice, by the way im using interbase IBConsole !!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
显然,Interbase 不支持派生表 (
SELECT FROM (SELECT) )。或者,至少是您正在使用的版本(我不能确定,我已经有一段时间没有使用 Interbase 了)。 Firebird 2.0 中添加了此功能。您在这里有两个选择:
更改您的方法,以便不使用
SELECT FROM (SELECT)
(派生表)OR
如果您有自主权,那么您绝对应该选择选项#2。
顺便说一句,Firebird 不要求您为派生表声明别名,尽管如果您要将派生表与其他表/派生表连接起来,这最终是必要的
Apparently, Interbase does not support derived tables (
SELECT FROM (SELECT)
). Or, at least, the version you are using (I cannot be sure, it's been a while since I don't work with Interbase). This feature was added in Firebird 2.0. You have two options here:Change your approach so that you don't use
SELECT FROM (SELECT)
(derived tables)OR
Upgrade to Firebird
If you have autonomy for that, you should definitively go with option #2.
BTW, Firebird does not require you to declare an alias for your derived table, although that will end up being necessary if you will have your derived table JOINED with other table(s)/derived table(s)
InterBase 不支持派生表。但它们对此查询没有任何好处,因此只需删除它即可:
...在这种情况下将为您提供与派生表相同的结果..
InterBase doesn't support derived tables. But they give you no benefit for this query, so just get rid of it:
...will give you the same results as a derived table would in this case..
您需要为子查询指定一个别名。
You need to give the subquery an alias.
我收到这个错误:
请尝试以下操作:
I got this error:
try something like: