Jump to content

Pbm wit subquery


shan_cool

Recommended Posts

hi all

 

 

my sub query is:

select Max(m.Start_Date)

from HR_Emp_Det e,

skill_master i,

tdm_proposal p,tdm_prj_mem_det m where

e.Emp_Id=i.Emp_Id and i.Emp_Id=m.Emp_Id and p.Prj_Code=m.Prj_Code and e.Emp_Status <> 'R' and m.Emp_Id='20' group by m.Emp_Id

 

This give me correct output.. this output is passed to the where condition of main query.

 

my main query is:

 

select e.Emp_Id,e.Emp_FName,

e.Emp_LName,e.Emp_Ug_Deg,

e.PG_Deg,e.Emp_Desgn,

e.Emp_DOJ,e.Base_Location,

e.Emp_Ug_Year,e.PG_Year,

i.Emp_Id,i.Test_Exp,i.Dev_Exp,

i.Other_Exp,p.Prj_Code,

p.Project_Name,p.Client,

p.Location,m.Prj_Code,

m.Emp_Id,Max(m.Start_Date) ,

IF(m.End_Date="",m.End_Date,

Max(m.End_Date)),m.cty

from HR_Emp_Det e,

skill_master i,

tdm_proposal p,tdm_prj_mem_det m where

e.Emp_Id=i.Emp_Id and i.Emp_Id=m.Emp_Id and p.Prj_Code=m.Prj_Code and e.Emp_Status <> 'R' and m.Emp_Id='20' and m.Start_Date='2003-02-01' group by m.Emp_Id

 

here i hav hard coded the date in where condition... it works fine.. but i need to merge both queries as:

 

 

select e.Emp_Id,e.Emp_FName,

e.Emp_LName,e.Emp_Ug_Deg,

e.PG_Deg,e.Emp_Desgn,

e.Emp_DOJ,e.Base_Location,

e.Emp_Ug_Year,e.PG_Year,

i.Emp_Id,i.Test_Exp,i.Dev_Exp,

i.Other_Exp,p.Prj_Code,

p.Project_Name,p.Client,

p.Location,m.Prj_Code,

m.Emp_Id,Max(m.Start_Date) ,

IF(m.End_Date="",m.End_Date,

Max(m.End_Date)),m.cty

from HR_Emp_Det e,

skill_master i,

tdm_proposal p,tdm_prj_mem_det m where

e.Emp_Id=i.Emp_Id and i.Emp_Id=m.Emp_Id and p.Prj_Code=m.Prj_Code and e.Emp_Status <> 'R' and m.Emp_Id='20' and m.Start_Date="select Max(m.Start_Date)

from HR_Emp_Det e,

skill_master i,

tdm_proposal p,tdm_prj_mem_det m where

e.Emp_Id=i.Emp_Id and i.Emp_Id=m.Emp_Id and p.Prj_Code=m.Prj_Code and e.Emp_Status <> 'R' and m.Emp_Id='20' group by m.Emp_Id "

group by m.Emp_Id

 

this doesn't work

gimme some idea how to implement this..

 

rgds,

shan

India...

Link to comment
https://forums.phpfreaks.com/topic/3099-pbm-wit-subquery/
Share on other sites

As indicated in the replies to your other [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=81826\" target=\"_blank\"]thread[/a] on the same topic, your MySQL version doesn't support this; furthermore, the correct way to use a subquery is to enclose the inner query in parentheses, not double quotes.

Link to comment
https://forums.phpfreaks.com/topic/3099-pbm-wit-subquery/#findComment-10414
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.