: SELECT W.*, IF((W.sale_start_date <= NOW() OR W.sale_start_date = '0000-00-00') AND (W.sale_end_date >= NOW() OR W.sale_end_date = '0000-00-00'), 1, 0) AS sale_active, (SELECT i.thumb_file FROM images i WHERE i.fk_product_id = W.WRIST_WATCH_ID AND i.image_type = 'Main' ORDER BY i.`id` DESC LIMIT 1) AS thumb_file FROM WRIST_WATCH W WHERE (W.`STATUS` = 'Active' OR W.`STATUS` = 'Hold') AND (1=1 AND 1=1 AND fk_manufacturer_id = 2 AND (`STATUS` = 'Active' OR `STATUS` = 'Hold') AND (( MANUFACTURER LIKE '%chronograph%' OR MODEL_NAME LIKE '%chronograph%' OR INVENTORY_NUM LIKE '%chronograph%' OR MOVEMENT_COMMENT LIKE '%chronograph%' OR MOVEMENT LIKE '%chronograph%' OR MODEL_NUM LIKE '%chronograph%' OR CONDITION LIKE '%chronograph%' OR GENDER LIKE '%chronograph%' OR _CASE_ LIKE '%chronograph%' OR BRACELET LIKE '%chronograph%' OR DIAL LIKE '%chronograph%' OR STRAP LIKE '%chronograph%' OR COMMENT LIKE '%chronograph%' OR stock_notes LIKE '%chronograph%' OR HIDDEN LIKE '%chronograph%')) ) ORDER BY W.CREATED DESC LIMIT 0, 48