title: Magento - SQL command to set "exclude" on product images
body: <p>I'm wondering if there's some SQL command I can run that will set any product with only 1 image to "exclude" that image from the image gallery. Adding the following will set all excludes to 1 (or tick the "exclude" image box in other words):</p>
  
  <pre><code>UPDATE catalog_product_entity_media_gallery_value
  SET disabled = 1
  </code></pre>
  
  <p>But I need to only do that for products with 1 image, and leave any products with more than 1 image "un-excluded" (or "disabled = 0").</p>
  
  <p>Magento version is 1.4.2.0. </p>
  
  <p>Cheers</p>
  
  <p>UPDATE: I found the following which is doing something similar, although I would want just products with only 1 image to be excluded:</p>
  
  <p>-- Set all images as enabled ("exclude" deselected)</p>
  
  <pre><code>update catalog_product_entity_media_gallery_value set disabled = 0;
  </code></pre>
  
  <p>-- Set all the main images as disabled ("exclude" selected) so that they do not show up in “More Views”</p>
  
  <pre><code>update catalog_product_entity_media_gallery_value set disabled=1 where value_id in (select value_id from catalog_product_entity_media_gallery where value in (select value
  from catalog_product_entity_varchar where attribute_id=(select attribute_id from eav_attribute where attribute_code=’image’ and entity_type_id=4)))
  </code></pre>