Jump to content


Photo

Pbm wit subquery


  • Please log in to reply
2 replies to this topic

#1 shan_cool

shan_cool
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts
  • LocationChennai,India

Posted 26 December 2005 - 09:47 AM

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

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 26 December 2005 - 03:41 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 shan_cool

shan_cool
  • Members
  • PipPipPip
  • Advanced Member
  • 53 posts
  • LocationChennai,India

Posted 27 December 2005 - 04:18 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users