INSERT INTO new_schedules_spider_shipsname ( ID,SCAC,VESSEL,VOYAGE,SERVICE_NAME,MD5 ) SELECT NULL,%s,%s,%s,%s,%s FROM DUAL WHERENOT EXISTS ( SELECT * FROM new_schedules_spider_shipsname s WHERE s.MD5 = %s and s.STATE =0 )