Skip to Content
author's profile photo Former Member
Former Member

Join statment is not working

Hello Experts,

I am trying to write a below code where i will be using JOIN statment to select data from 2 table faglflexas and cepct.These two tables have only one field in common(prctr).I would also be getting the value of prctr from the user on selection screen.

But the code syntax is not allowing me to prctr in both the places.

SELECT faglflexapoper faglflexaryear faglflexaprctr cepctktext " FROM faglflexa

INTO CORRESPONDING FIELDS OF TABLE gi_prctr

FROM cepct JOIN faglflexa ON cepctprctr = faglflexaprctr

WHERE poper IN s_period

AND ryear EQ p_fyear.

AND prctr in s_prctr.

I am getting error in last line of AND prctr in s_prctr. asking that I prctr is defined in two places in the select query.

please help.

points will be rewarded definately.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 02:17 AM

    Hi,

    The code written by you is giving a syntax error as PRCTR field is present in both the tables and you are using a join but in the where clause you are not specifying the field with respect to a table.

    try the below syntax:

    SELECT faglflexapoper faglflexaryear faglflexaprctr cepctktext " FROM faglflexa

    INTO CORRESPONDING FIELDS OF TABLE gi_prctr

    FROM cepct JOIN faglflexa ON cepctprctr = faglflexaprctr

    WHERE poper IN s_period

    AND ryear EQ p_fyear.

    AND cepct~prctr in s_prctr.

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 23, 2008 at 02:19 AM

    Try this way

    SELECT faglflexa~poper faglflexa~ryear faglflexa~prctr cepct~ktext " FROM faglflexa
    INTO CORRESPONDING FIELDS OF TABLE gi_prctr
    FROM cepct INNER JOIN faglflexa ON cepct~prctr = faglflexa~prctr
    WHERE faglflexa~poper IN s_period
    AND faglflexa~ryear EQ p_fyear.
    AND faglflexa~prctr in s_prctr.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 23, 2008 at 02:22 AM

    Hi,

    there is small mistake in your query, just try this one.

    SELECT faglflexapoper faglflexaryear faglflexaprctr cepctktext " FROM faglflexa

    INTO CORRESPONDING FIELDS OF TABLE gi_prctr

    FROM cepct JOIN faglflexa ON cepctprctr = faglflexaprctr

    WHERE poper IN s_period

    AND ryear EQ p_fyear.

    AND faglflexa~prctr in s_prctr.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.