View previous topic :: View next topic
|
Author |
Message |
kalinga
New User
Joined: 25 May 2005 Posts: 4 Location: chennai,india
|
|
|
|
hi,
say i'm having a table called EMP_TABLE, in that the columns are emp_id,sal,name,loc.
EMP_DEP HAS SOME COLUMNS
i am executing the query USING CURSOR SELECT * FROM EMP_TABLE, EMP_DEP. I WANT TO GET THE ANSWER LIKE BELOW
EMP_TABLE 100 9999 xyz mum
EMP_DEP 92K RUBBER SOFA
EMP_TABLE 200 8888 zyx chn
EMP_DEP 34S STEEL BUS
AND SO ...............ON |
|
Back to top |
|
|
vasanthanc
New User
Joined: 01 Apr 2005 Posts: 58
|
|
|
|
But why do you want the table name in your result, that to when u r using cursor ?
Lets come to your question. How do you compare which emp belongs to which department? There should be a common field. (i.e) there should be a field in emp_table like emp_dept_no and similar field should be there in emp_dep table also. then u can write the query as
Select * from Emp_Table, Emp_Dept
where EMP_TABLE.EMP_DEPT_NO = EMP_DEP.DEPT_NO
I think, this is what you needed (?) |
|
Back to top |
|
|
MGIndaco
Active User
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
If you are running a Cobol program you can have your columns in the way you need. If you use a DCL and you fetch with your coursor you can establish the direction of data and name of columns.
But if you need display the same information as the sample above in QMF you must use a most complex query that needs information NAME from the SYSIBM.SYSCOLUMNS. |
|
Back to top |
|
|
|