此刻,我正在使用Firebird与InterBase一起工作。我需要两次获得一个条件的记录,但是每次运行查询时,我都会不断收到错误消息。有没有一种方法可以解决InterBase中的交叉联接问题?是否有一种更简单的方法来解决这个逻辑添加到查询中。看来Firebird不会接受交叉加入。
SELECT EMPLOYEE_NAME, LAST_NAME, CACODE
FROM EMPLOYEESTABLE
(
SELECT 889 AS CACODE, 8592-265-44444 AS STANDARDCACODE
UNION ALL
SELECT 695 AS CACODE, 8554-265-44578 AS STANDARDCACODE
) C
答案 0 :(得分:2)
选择始终需要from
。表RDB$DATABASE
返回带有数据库名称的1行,因此我们可以使用它。我想您正在寻找这样做:
SELECT EMPLOYEE_NAME, LAST_NAME, CACODE
FROM EMPLOYEESTABLE,
(
SELECT 889 AS CACODE, '8592-265-44444' AS STANDARDCACODE FROM RDB$DATABASE
UNION ALL
SELECT 695 AS CACODE, '8554-265-44578' AS STANDARDCACODE FROM RDB$DATABASE
) C
答案 1 :(得分:0)
SELECT
889 AS CACODE,
/* '8592-265-44444' AS STANDARDCACODE, >>unused<< */
EMPLOYEE_NAME,
LAST_NAME
FROM EMPLOYEESTABLE
UNION ALL
SELECT
695 AS CACODE,
/* '8554-265-44578' AS STANDARDCACODE, >>unused<< */
EMPLOYEE_NAME,
LAST_NAME
FROM EMPLOYEESTABLE
谁需要加入这样的简单查询:-D