Search code examples
mysqlselectprocedures

Clear the result set in a MySQL procedure


I want to define a MySQL stored procedure, which returns data in the result set. Sometimes, I want to return nothing (ie, zero rows).

How can I do this? SELECT; is invalid, and SELECT NULL; returns a record with a NULL value. How to select an empty set?


Solution

  • This does the trick:

    mysql> select null from dual where 1=0;
    Empty set (0.00 sec)