Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

selecting from two table

Former Member
0 Likes
1,600

Hi all,

I'm now work in a table that compine data from tow table .

table display employee Id, employee name, a_time, l_time, and delay.

ztable1 contain  employee Id, date, a_time, l_time, and delay.

ztable2 contain  employee Id, employee name.

*select
*
*  A~EMPLOYEE_ID
*  B~EMP_NAME
*  A~A_TIME
*  A~L_TIME
*  A~DELAY into CORRESPONDING FIELDS OF TABLE internaltable

*FROM ztable1 as A  INNER JOIN  ztable2 as B on A~EMPLOYEE_ID = B~EMP_ID and A~DATE1 = spisified_date.

No result found, and there is no errors in the code.Could any one help???? I think there is error in the select statment.

thanks for all.

13 REPLIES 13
Read only

0 Likes
1,565

Hello Huda

please insert in the code the WHERE sentence after the ON sentence,

Best regards

DL

Read only

0 Likes
1,565

*Select  A~EMPLOYEE_ID

*  B~EMP_NAME

*  A~A_TIME

*  A~L_TIME

*  A~DELAY into TABLE lt_attendance_node

*from ztable1 as A

*inner join  ztable2 as B on EMPLOYEE_ID = B~EMP_ID where A~DATE1 = spisified_date.

still didn't work ,, Iwant to select all table1 ,and the name of employee from another table

Read only

Former Member
0 Likes
1,565

Hi Huda,

The select query looks fine. Since it's a ZTable, please check if the data exists in corresponding tables for your search criteria given in the query.

That might be an issue.

Thanks

Vivek

Read only

0 Likes
1,565

Hi Not Active Contributor

Read only

0 Likes
1,565

Hi Huda,

in your 1st post, u mentioned the structure of your Z tables as below :

ztable1 contain  employee Id, date, a_time, l_time, and delay.

ztable2 contain  employee Id, employee name.

but in your query , it's written, B~EMP_ID  ??

select
*
*  A~EMPLOYEE_ID
*  B~EMP_NAME
*  A~A_TIME
*  A~L_TIME
*  A~DELAY into CORRESPONDING FIELDS OF TABLE internaltable

*FROM ztable1 as A  INNER JOIN  ztable2 as B on A~EMPLOYEE_ID = B~EMPLOYEE_ID and A~DATE1 = spisified_date.

This should work

Thanks

Vivek

Read only

0 Likes
1,565

Hello Huda,

i think you have to create a foreign key relationship between both tables based on employee id......

hope your problem will be solved...

Thanks

Sabyasachi

Read only

0 Likes
1,565

ztable1:

CLIENT type  MANDT

ATT_ID type Z_ID

EMPLOYEE_ID  typeZEMPLOYEE_ID

DATE1 type  ZDATE

A_TIME  type ZATIME

L_TIME  type ZLTIME

PERM_ type TIME ZPERM_TIME

DELAY type  ZDELAY

ztable2:

CLIENT  type MANDT

EMP_ID type  Z_ID

EMP_NAME type  Z_NAME

TIM_ID  type Z_ID

PASSWORD  type ZPASS

Appreciate your cooperation

Read only

0 Likes
1,565

Hello,

in Ztable1 :

EMPLOYEE_ID  typeZEMPLOYEE_ID

in your ztable2

EMP_ID type  Z_ID.

check that both domain are same or not??.....to create a foreign key relationship both domain must be same.. create a foreign key relationship......then execute your code......

Hope it will be helpfull.......

Thanks

Sabyasachi

Read only

0 Likes
1,565

It's work

I change the data type in the table after deleting all data ......and it work now .....thank you very much for your help

Read only

Former Member
0 Likes
1,565

hello Huda,

table1 and table 2 both has a field employee_id....check both domain and data type and no. of characters in both tables..... any foreign key relationship has already been created between those table???

Thanks

Sabyasachi

Read only

0 Likes
1,565

I thenk this is will help ,,I will make forign key

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,565

Try

SELECT A~EMPLOYEE_ID B~EMP_NAME A~A_TIME A~L_TIME A~DELAY

  INTO itab as A

  INNER JOIN ztable2 as B

    on  A~EMPLOYEE_ID = B~EMP_ID

  WHERE

     A~DATE1 = spisified_date.

Regards,

Raymond

Read only

Former Member
0 Likes
1,565

Hi Huda..

whenever you are writing a select statement to get the data from database table into the internal table

dont use into corresponding fields of table i-tab...it is a big performance issue..instead you use the same structure what you had declared ...