Hi,
So this is a bit off topic and more of a question than anything else but I’ve been struggling over this SQL problem all day and wondered if anybody out there could offer a quick bit of advice! Is there anything wrong with this code?
CREATE PROCEDURE `catalog_get_product_locations`(IN inProductId INT)
BEGIN SELECT aa.cat_id, aa.cat_name AS cat_name, aa.dept_id AS dept_name
FROM cb_category aa
INNER JOIN cb_department bb ON bb.dept_id = aa.dept_id
WHERE aa.cat_id
IN (
SELECT cat_id
FROM cb_product_category
WHERE prod_id = inProductId
);
END$$It’s a stored procedure but when I serve it up I get the following error:
Column not found: 1054 Unknown column ‘aa.dept_id’ in ‘field list’
Surely the table join should mean the cb_department dept_id row is linked to the cb_category table?
Any help would be greatly appreciated!
Thanks,
Steve