Return a default value if single row is not found

One way to do it SELECT IFNULL(MIN(`file`), ‘default.webm’) `file` FROM `show`, `schedule` WHERE `channel` = 1 AND `start_time` <= UNIX_TIMESTAMP() AND `start_time` > UNIX_TIMESTAMP()-1800 AND `show`.`id` = `schedule`.`file` ORDER BY `start_time` DESC LIMIT 1 Since you return only one row, you can use an aggregate function, in that case MIN(), that ensures that you’ll get … Read more

Is there a “null coalescing” operator in JavaScript?

Update JavaScript now supports the nullish coalescing operator (??). It returns its right-hand-side operand when its left-hand-side operand is null or undefined, and otherwise returns its left-hand-side operand. Old Answer Please check compatibility before using it. The JavaScript equivalent of the C# null coalescing operator (??) is using a logical OR (||): var whatIWant = … Read more