I'm trying to extend a 2 table join query to join 3 tables. I'm using PDO
SELECT tb.product, COUNT(tb.ID) AS nums FROM items tb LEFT JOIN itemCode cod ON tb.ID = cod.codeID WHERE tb.product = :product AND cod.name = :cName
The above 2 table join works. My question is, how do I match itemCode
's availabilityID
column to tblC
's stockID
column and add it to the WHERE
clause with same query to get the result?
So basically I want to check if the availabilityID
column of itemCode
table match with stockID
column of tblC
table.
EDIT: table structure:
**items table**
ID | product
**itemCode table**
codeID | name
**tblC table**
stockID