raindrops87 Posted February 3, 2011 Share Posted February 3, 2011 hi can anybody help me with this query? select rawmatno, rawmatname, qty from compofrawmat join rawmaterials on compofrawmat.rawmatno = rawmaterials.rawmatid where ProductId in(select ProductId, sum(Quantity) from (customerorderform join cofdetails on customerorderform.OrderNo = cofdetails.OrderNo) natural join finishedproduct where customerorderform.DatePickUp >= adddate(curdate(), interval 3 month) and customerorderform.DatePickUp <= adddate(curdate(), interval 6 month) group by ProductName) when i use this i get an error that says operand should contain 1 column(s) but if i remove sum(Quantity) it works but i need to add the quantity of the finishedproducts by id to multiply it to the qty of its raw materials. any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/226531-error-operand-should-contain-1-columns/ Share on other sites More sharing options...
requinix Posted February 3, 2011 Share Posted February 3, 2011 If you need both pieces of data then an IN is not what you should be using. Try a JOIN instead. Quote Link to comment https://forums.phpfreaks.com/topic/226531-error-operand-should-contain-1-columns/#findComment-1169220 Share on other sites More sharing options...
raindrops87 Posted February 3, 2011 Author Share Posted February 3, 2011 what i need is to get the quantity of raw materials that comprises the finished products for the next 4-6 months that are found in the customer order form. do i need a join or in? Quote Link to comment https://forums.phpfreaks.com/topic/226531-error-operand-should-contain-1-columns/#findComment-1169251 Share on other sites More sharing options...
requinix Posted February 3, 2011 Share Posted February 3, 2011 do i need a join or in? Yes. With your current query an IN will not work. So you have [more than these] two options: try a JOIN instead, or keep your IN but change the query to be able to use it. Quote Link to comment https://forums.phpfreaks.com/topic/226531-error-operand-should-contain-1-columns/#findComment-1169253 Share on other sites More sharing options...
raindrops87 Posted February 3, 2011 Author Share Posted February 3, 2011 but if i use join another error comes up, column productid in field list is ambiguous Quote Link to comment https://forums.phpfreaks.com/topic/226531-error-operand-should-contain-1-columns/#findComment-1169268 Share on other sites More sharing options...
awjudd Posted February 3, 2011 Share Posted February 3, 2011 Then fully qualify the field name (table.field) in your returned table? ~judda Quote Link to comment https://forums.phpfreaks.com/topic/226531-error-operand-should-contain-1-columns/#findComment-1169370 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.