I am trying to use the outer table in a sub query select. While I can hardcode the value and get the required results; I really need to use the outer phppos_items table; but cannot figure it out. Below is the simplified query. Is there any way to do this? The reason I am using a sub query as I want to get only one row in the join.
The part I am trying to get the outer table is XXX
SELECT SUM(trans_current_quantity) as quantity FROM `phppos_items`
LEFT JOIN `phppos_location_items` ON `phppos_location_items`.`item_id` = `phppos_items`.`item_id` and `phppos_location_items`.`location_id` IN(1)
LEFT JOIN
(SELECT * FROM phppos_inventory WHERE trans_date < '2018-05-06 23:59:59' and
trans_items = *XXX* ORDER BY trans_date DESC LIMIT 1) as inventory
ON `phppos_location_items`.`item_id` = `inventory`.`trans_items`