How To Override Null Value From Aggregate Query Using Mysqldb Module In Python?
I am selecting the maximum date value from a MySQL database table in python using the MySQLdb module. If the result comes back as null, I want to override it with a default value.
Solution 1:
I could do this in the MySQL using a sub-query, but would prefer to do it in python.
Why do you say you need a subquery? You can just use COALESCE:
"select COALESCE(max(date_val), 'your_default_value_here') from my_table;"
Post a Comment for "How To Override Null Value From Aggregate Query Using Mysqldb Module In Python?"