How can I "pass a value" into a MYSQL subquery?

QuestionsHow can I "pass a value" into a MYSQL subquery?
sethbeckerman5 Staff asked 4 years ago

I need to pass the OD.ID from the parent query's current record to the subquery. I have no idea how to do this, or even if it's possible to do.
The value of OD.ID (line 4 below) will be a unique number for each row in the parent query, and I need to limit the subquery to only records in the OD table that have that ID (attempted on line 10 below). The goal is for the query on line 10 to return a value representing the number of distinct days a person with the given ID has placed an order. The OD database contains a record for each individual item purchased for every order and has columns for purchase day and ID of the purchaser, among other columns. Is it possible to do this?


View on Stack Overflow