SELECT IF(MAX(`id`),MAX(`id`)+1, 1) max_id FROM `testbl1`
SELECT IF(MAX(`id`) IS NOT NULL, MAX(`id`)+1, 1 ) mx_id FROM `table1`