Jump to content

Subquery to get value from one table based on another table


ShadowMage

Recommended Posts

I have two tables: OrderHed and OrderRel.  There are multiple records in OrderRel for each OrderHed.  I'm trying to pull out the first record from OrderRel for each OrderHed.  I have the following query, but it gives me a "Function sequence error"

SELECT OrderHed.OrderNum, OrderRel.Plant
FROM OrderHed INNER JOIN (SELECT Plant FROM OrderRel WHERE OrderRel.OrderNum = OrderHed.OrderNum LIMIT 1) OrdRel
WHERE ((OrderHed.OpenOrder <> 0) AND (OrderHed.VoidOrder = 0)) 
ORDER BY OrderHed.OrderNum DESC

Can anyone help me, please?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...