A function to check if a column allows NULL
You can query the INFORMATION_SCHEMA:
http://dev.mysql.com/doc/refman/5.0/en/columns-table.html
In the INFORMATION_SCHEMA.COLUMNS table there is a IS_NULLABLE column.
You could turn it into a function, I imagine, but I would probably put this logic in an outer part.
Cade's answer is correct, but the information directly from the link:
SELECT COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'mytable'