带有子查询

时间:2016-07-15 12:34:46

标签: sql hana-sql-script

我有像这样的SQL语句的问题

SELECT e.id, e.name, d.name as department_id

FROM (FROM (SELECT id, name, department_id
            FROM employee
            WHERE address = 'Texas' ) e
     JOIN department d
     ON e.department_id = d.id )

WHERE CONTAINS( (e.name, d.name), 'user_input_for_search')

执行SQL时,收到错误消息: “功能不受支持:全文搜索功能不支持子查询中的列”

有人可以教我如何解决它吗?

由于

2 个答案:

答案 0 :(得分:0)

我不是100%肯定,但我会尝试一下:)。

子查询是否有原因?除非我遗漏了某些东西,否则它看起来并不需要。这不行吗?

SELECT e.id, e.name, d.name as department_id
FROM employee e JOIN department d ON e.department_id = d.id
WHERE e.address = 'Texas' AND CONTAINS((e.name, d.name), 'user_input_for_search')

答案 1 :(得分:0)

/********* Begin Procedure Script ************/ 
VENNAMEFUZZ DECIMAL;

BEGIN 

VENNAMEFUZZ = 0.8;
------ SELECTION PRO  -----------------------------------
    LT_1 = 

        SELECT DISTINCT
        "AK"."LIFNR" AS VENDORNUMB,
        "EC"."NAME1" AS VENDORNAME

       FROM
        "BSAK" AS "AK"

        LEFT OUTER JOIN
        "BSEC" AS "EC"

        ON
          "AK"."BUKRS" = "EC"."BUKRS" AND 
          "AK"."BELNR" = "EC"."BELNR" AND
          "AK"."GJAHR" = "EC"."GJAHR" AND
          "AK"."BUZEI" = "EC"."BUZEI"

        WHERE
        "AK"."MANDT" = SESSION_CONTEXT('CLIENT') AND
        "AK"."LIFNR" LIKE '0011%' AND
        "AK"."BSCHL" IN ('31', '32', '34' , '21', '22' , '24' ) AND
        "AK"."BUKRS" = 'RO01' AND
        "AK"."BLDAT" >= '20160801'
        AND "AK"."BLDAT" <= '20160808';   

LT_5= 

    SELECT DISTINCT
    "IT"."VENDORNUMB" AS VENDORNUMB,
    "IT"."VENDORNAME" AS VENDORNAME 

    FROM 
    :LT_1 AS "IT";

IT_1 = 

    SELECT DISTINCT
    "AK"."LIFNR" AS VENDORNUMB,
    "EC"."NAME1" AS VENDORNAME

    FROM
        "BSAK" AS "AK"

    LEFT OUTER JOIN
        "BSEC" AS "EC"

    ON
      "AK"."BUKRS" = "EC"."BUKRS" AND 
      "AK"."BELNR" = "EC"."BELNR" AND
      "AK"."GJAHR" = "EC"."GJAHR" AND
      "AK"."BUZEI" = "EC"."BUZEI"

    WHERE
        "AK"."MANDT" = SESSION_CONTEXT('CLIENT') AND
        "AK"."LIFNR" LIKE '0011%' AND
        "AK"."BSCHL" IN ('31', '32', '34' , '21', '22' , '24' ) AND
        "AK"."BUKRS" = 'RO01';      

----SETTING CURSOR

BEGIN
DECLARE CURSOR c_WS FOR SELECT * FROM :LT_5;
FOR WS_row AS c_WS() DO

VAR_OUT= 

SELECT * FROM :VAR_OUT

UNION ALL(
SELECT
WS_ROW.VENDORNUMB,
VENDORNAME

FROM
:IT_1

WHERE
 CONTAINS(VENDORNAME,WS_ROW.VENDORNAME , FUZZY(:VENNAMEFUZZ)));
END FOR;
END ; 

Please help as I am facing the same error in above code.