Home » RDBMS Server » Server Administration » help joining 3 tables with filtering records
help joining 3 tables with filtering records [message #373532] Sun, 22 April 2001 01:23 Go to next message
amul
Messages: 252
Registered: April 2001
Location: Chennai
Senior Member
SELECT M.EMP_NO,M.INOUT_DATE,M.INOUT_FLAG,M.TRANSACTION_FLAG,
E.EMP_NO,E.FLEX_NO,
F.FLEX_NO,F.FLEX_DESCRIPTION,
EM.EMP_NO
FROM FLEX_MASTER F,
EMPLOYEE_MASTER E,
MONTHLY_EMP_ATTENDANCE M,
MONTHLY_EMP_ATTENDANCE EM
WHERE M.EMP_NO = E.EMP_NO
AND E.FLEX_NO = F.FLEX_NO
AND EM.EMP_NO = (SELECT EMP_NO FROM MONTHLY_EMP_ATTENDANCE WHERE INOUT_FLAG=3)
/
THIS QUERY DOEST WORK CAN ANY BODY HELP URGENT!!!!!!!
IS THERE ANY BETTER WAY TO WRITE QUERY JOINING 3 TABLES WITH FILTERING ????
PL.HELP
Re: help joining 3 tables with filtering records [message #373535 is a reply to message #373532] Sun, 22 April 2001 19:34 Go to previous messageGo to next message
Joseph Stiehm
Messages: 4
Registered: April 2001
Junior Member
As written, this SQL would produce a cartesian product of the intermediate result joining tables F, E, & M with EM. Is this intentional? The following SQL eliminates the second alias to MONTHLY_EMP_ATTENDANCE and filters the records:

SELECT M.EMP_NO,M.INOUT_DATE,M.INOUT_FLAG,M.TRANSACTION_FLAG,
E.EMP_NO,E.FLEX_NO,
F.FLEX_NO,F.FLEX_DESCRIPTION
FROM FLEX_MASTER F,
EMPLOYEE_MASTER E,
MONTHLY_EMP_ATTENDANCE M
WHERE M.EMP_NO = E.EMP_NO
AND E.FLEX_NO = F.FLEX_NO
AND M.INOUT_FLAG = 3

Let me know if this helps.

Joseph Stiehm
Re: help joining 3 tables with filtering records [message #373540 is a reply to message #373532] Mon, 23 April 2001 00:23 Go to previous message
Mr.Joseph Stiehm
Messages: 1
Registered: April 2001
Junior Member
Thank's for your help. hope it will work.

regards
Amul
Previous Topic: phone format
Next Topic: star schema to denormalized table
Goto Forum:
  


Current Time: Mon Dec 23 10:32:21 CST 2024