Bug #13939 extension to SQL syntax: SELECT DEFAULT_IF_NULL

Submitted: 11 Oct 2005 20:55 Modified: 15 Dec 2010 11:15
Reporter: SweetAs Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S4 (Feature request)
Version:n/a OS:Any (n/a)
Assigned to: CPU Architecture:Any

[11 Oct 2005 20:55] SweetAs
Description:
at present, DEFAULT applies to insertion of data rather than on SELECT.

if you apply a new default value, to a col on a table that already contains data, the existing rows will not contain the default value.

an SELECT DEFAULT_IF_NULL would return the default value of a col in the instance that the field contained no data.

the same effect could be achieved with something like SELECT COALESCE(DEFAULT(colname),colname), but if i had a hundred cols i wanted this to apply too it would mean typing this out a hundred times.

thanks

How to repeat:
n/a

Suggested fix:
n/a
[15 Dec 2010 11:15] Valeriy Kravchuk
Makes some sense, when many columns are selected (or as SQL Server compatibility feature). But for most cases workarounds like mentioned or IFNULL(col1, DEFAULT(col1)) will work.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.049 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.