Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables

MPL_DET(JobNo(pk), SystName, ReqQty )

MPL_ITDET( ID(pk), JobNo(FK), IT_Name, QtyPSys, IssQty)


I want to select the JobNo from MPL_DET where

MPL_ITDET.IssQty < MPL_ITDET.QtyPSys * MPL_DET.ReqQty

(Problem is MPL_DET.ReqQty will give multiple records
but i want the record belongs to perticular JobNo)

Sorry if my question is not clear!
Posted

try this
SQL
SELECT JobNo from MPL_DET MD INNER JOIN MPL_ITDET MID ON MD.JobNo = MID.JobNo
WHERE MID.IssQty < ( MID.QtyPSys * MD.ReqQty )
 
Share this answer
 
Comments
OriginalGriff 13-Nov-13 7:16am    
If you are going to change someone else's answer, it is polite to mark what you have done.
In this case, you added the word "INNER" to my solution which is superfluous: a JOIN is an INNER JOIN unless otherwise specifically stated. You only need to use INNER when your query contains other forms of JOIN as well to reduce any possible confusion.
In this case, INNER is not needed as there is only the one JOIN in the query, and I have removed it from my answer again.
prashant patil 4987 14-Nov-13 0:53am    
ok.. i got it OriginalGriff
Thanks for information.
OriginalGriff 13-Nov-13 7:18am    
Particularly when your change makes the query then not work because you removed the table alias from it to get the INNER in!
prashant patil 4987 14-Nov-13 0:54am    
I thouht u miss the word INNER thatsy m correcting your answer.
but now i got your point.
thanks
Prashant Patil
From INDIA.
Try:
SQL
SELECT d.JobNo FROM MPL_ITEDT i
JOIN MPL_DET d 
ON i.JobNo=d.JobNo
WHERE i.IssQty < (i.QtyPsys * d.ReqQty)


[edit]Rolled back superfluous changes made by other - OriginalGriff[/edit]
 
Share this answer
 
v4
Comments
Manzoor Ahmed P 13-Nov-13 5:42am    
Thank you friends!
OriginalGriff 13-Nov-13 5:49am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900