Fetch value/values from table : <p>I have the following table in my database</p>

<pre><code>CREATE TABLE `sms_pool` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `ag_id` VARCHAR(20) NOT NULL,
    `sms_to` VARCHAR(15) NOT NULL,
    `template_name` VARCHAR(100) NOT NULL,
    `contents` VARCHAR(500) NOT NULL,
    `bulk_flag` VARCHAR(1) NOT NULL,
    `file_name` VARCHAR(100) NULL DEFAULT NULL,
    `send_flag` VARCHAR(1) NOT NULL,
    `creation_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `created_by` VARCHAR(20) NOT NULL,
    `processing_msg` VARCHAR(2000) NULL DEFAULT NULL,
    PRIMARY KEY (`id`),    
);
</code></pre>

<p>I wish to write a procedure/function which takes 'id' as input.</p>

<p>If that 'id' is equal to any id in table then it should return the corresponding row,</p>

<p>if 'id' = NULL then it should return all of the rows from the database.</p>

<p><strong>NOTE</strong> : if 'id' is not present in table then it should return all of the rows.</p>

<p>How should I do this? Any help is appreciated. Thank you in advance. :D</p>
