Search code examples
mysqlsqlmysql-error-1241

#1241 - Operand should contain 1 column(s) - why am i getting this?


I am trying to run a query but I am getting the above error. can anyone let me know why am I getting it.

UPDATE `catalog_eav_attribute`
SET `used_for_sort_by` = 1
WHERE attribute_id = (
SELECT * FROM `eav_attribute` WHERE `entity_type_id` = (SELECT `entity_type_id` FROM `eav_entity_type` WHERE `entity_model` = "catalog/product") AND `attribute_code` = "created_at");

Solution

  • You have attribute_id = (select * . . .. Presumably, eav_attribute has more than one column.

    You need to specify the particular column, something like this:

    UPDATE `catalog_eav_attribute`
        SET `used_for_sort_by` = 1
        WHERE attribute_id = (SELECT ea.attribute_id  -- this is a guess
                              FROM `eav_attribute` ea
                              WHERE `entity_type_id` = (SELECT `entity_type_id` 
                                                        FROM `eav_entity_type` 
                                                        WHERE `entity_model` = 'catalog/product'
                                                       ) AND
                                   `attribute_code` = 'created_at'
                             );