mysql> SELECT IFNULL(0, 123);
+----------------+
| IFNULL(0, 123) |
+----------------+
| 0 |
+----------------+
1 row in set (0.00 sec)
mysql> SELECT IFNULL(1, 123);
+----------------+
| IFNULL(1, 123) |
+----------------+
| 1 |
+----------------+
1 row in set (0.00 sec)
mysql> SELECT IFNULL(NULL, 123);
+-------------------+
| IFNULL(NULL, 123) |
+-------------------+
| 123 |
+-------------------+
1 row in set (0.00 sec)
mysql> SELECT COALESCE(0, 123);
+------------------+
| COALESCE(0, 123) |
+------------------+
| 0 |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT COALESCE(1, 123);
+------------------+
| COALESCE(1, 123) |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
mysql> SELECT COALESCE(NULL, 123);
+---------------------+
| COALESCE(NULL, 123) |
+---------------------+
| 123 |
+---------------------+
1 row in set (0.00 sec)
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
my $having = "";
if ($dbdriver eq "mysql") {
$select .= "
- aqorders.quantity - IFNULL(aqorders.quantityreceived,0) AS quantity,
- (aqorders.quantity - IFNULL(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
+ aqorders.quantity - COALESCE(aqorders.quantityreceived,0) AS quantity,
+ (aqorders.quantity - COALESCE(aqorders.quantityreceived,0)) * aqorders.rrp AS subtotal,
DATEDIFF(CAST(now() AS date),closedate) AS latesince
";
if ( defined $delay ) {
)
AND aqorders.rrp <> 0
AND aqorders.ecost <> 0
- AND aqorders.quantity - IFNULL(aqorders.quantityreceived,0) <> 0
+ AND aqorders.quantity - COALESCE(aqorders.quantityreceived,0) <> 0
AND aqbasket.closedate IS NOT NULL
";
if ( defined $delay ) {
my $dbh = C4::Context->dbh;
my $query = qq/
- SELECT IFNULL(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, IFNULL(sh.borrowernumber,0) AS borrowernumber
+ SELECT COALESCE(owner,0) AS owner, category, allow_add, allow_delete_own, allow_delete_other, COALESCE(sh.borrowernumber,0) AS borrowernumber
FROM virtualshelves vs
LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
AND sh.borrowernumber=?