SELECT id, code, base_id, block_id FROM Table
WHERE code=123456 AND base_id=??????? AND block_id=?????? LIMIT 0,3
UNION ALL
SELECT id, code, base_id, block_id FROM Table LIMIT 0,2
WHERE code=678901 AND base_id=??????? AND block_id=?????? LIMIT 0,2
Возможно поможет!