: 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 = 6 AND ( (`STATUS` = 'Active' OR `STATUS` = 'Hold') ) AND (( MANUFACTURER LIKE '%Marine%' OR MODEL_NAME LIKE '%Marine%' OR INVENTORY_NUM LIKE '%Marine%' OR MOVEMENT_COMMENT LIKE '%Marine%' OR MOVEMENT LIKE '%Marine%' OR MODEL_NUM LIKE '%Marine%' OR CONDITION LIKE '%Marine%' OR GENDER LIKE '%Marine%' OR _CASE_ LIKE '%Marine%' OR BRACELET LIKE '%Marine%' OR DIAL LIKE '%Marine%' OR STRAP LIKE '%Marine%' OR COMMENT LIKE '%Marine%' OR stock_notes LIKE '%Marine%' OR HIDDEN LIKE '%Marine%')) ) ORDER BY W.CREATED DESC LIMIT 0, 48