E
E
Ellik2015-11-19 21:43:11
PHP
Ellik, 2015-11-19 21:43:11

How to sort a multipart query?

There is the following query, which gets the product entity, with attributes and values.
How to display products in which value_id = 2?
Thank you very much for the help !!!

SELECT `entity`.`entity_name` as `entity_name`,
  GROUP_CONCAT(CONCAT(`group`.`title`, '::', CONCAT(`atr`.`attribute_name`, ':' , `val`.`value_name`)) SEPARATOR ':::') as `attributes`
FROM `eav_entities` as `entity` 
JOIN `products` as `products` ON (`entity`.`entity_id` = `products`.`entity_id`)
JOIN `eav_attributes` as `atr` ON (`products`.`attribute_id` = `atr`.`attribute_id`)
JOIN `eav_values` as `val` ON (`products`.`value_id` = `val`.`value_id`)
JOIN `group_attributes` as `group` ON (`atr`.`group_id` = `group`.`group_id`)
WHERE `products`.`cat_id` = '9'
GROUP BY `entity`.`entity_name`

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marat, 2015-11-20
@Joysi75

Or is there a catch in the question, or in the original question, change the line to

JOIN `eav_values` as `val` ON (`products`.`value_id` = `val`.`value_id` and `products`.`value_id`=2)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question