Search code examples
phpmysqlmysql-error-1241

#1241 - Operand should contain 1 column(s)


In the following query am trying to get one image per category

SELECT  l.*
FROM    (
   SELECT  id AS category_id,
           COALESCE(
           (
           SELECT  *
           FROM    images li
           WHERE li.category_id = dlo.id

           ORDER BY
                       li.save_status DESC, li.category_id DESC, li.id DESC
           LIMIT 1
           ), 0) AS mid
   FROM    cats_imgs dlo where id='1'
   ) lo
JOIN    images l
ON      l.save_status = '3'
   AND l.category_id >= lo.category_id
   AND l.category_id <= lo.category_id
   AND l.id >= lo.mid

but keep getting the following error :

#1241 - Operand should contain 1 column(s)

Any ideas ?


Solution

  • replace * with a single column for images li