I have a mysql query which I've written in order to grab a group of attributes in the database based on IDs, which relate to a specific group. I'm using OpenCart 2 for my site, and my subquery is as follows:
SELECT GROUP_CONCAT(attribute_id) AS attr_ids
FROM oc79_attribute
WHERE attribute_group_id = 13
Which returns:
44,45,46,47
When I write this within the query which I need to get the attribute names, I only get one result:
SELECT *
FROM oc79_attribute_description
WHERE attribute_id IN(SELECT GROUP_CONCAT(attribute_id) AS attr_ids
FROM oc79_attribute WHERE attribute_group_id = 13)
I only get the result from attribute_id 44, and not the others even though I know the records exist.
Is this the right way to approach this, or am I just missing something?
EDIT:
To clarify, if I write:
SELECT * FROM oc79_attribute_description WHERE attribute_id IN(44,45,46,47)
I get the correct result of 4 records.
Thanks in advance