Jump to content

Archived

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

shan_cool

Pbm wit subquery

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...

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

hi ,

thank u verymuch for ur reply.................. i used parenthesis... but still query is being executed successfully but no records r displayed.

 

may b the pbm wit mysql version as u said....

 

rgds,

shan,

India...

Share this post


Link to post
Share on other sites

×

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.