1
0
Fork 0

Return both website and hide_website fields (for use on an admin page). Using COALESCE to return 0 and an empty string if there is no reply to not deal with NULL.

This commit is contained in:
Alexander Andreev 2023-05-09 21:30:17 +04:00
parent 613f0c1616
commit 6cfe0a7d8b
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 4 additions and 7 deletions

View File

@ -3,13 +3,10 @@ SELECT
`entry`.`created`, `entry`.`created`,
`entry`.`name`, `entry`.`name`,
`entry`.`message`, `entry`.`message`,
CASE `entry`.`website`,
WHEN `entry`.`hide_website` IS FALSE `entry`.`hide_website`,
THEN `entry`.`website` COALESCE(`reply`.`created`, 0) AS `reply_created`,
ELSE '' COALESCE(`reply`.`message`, '') AS `reply_message`
END AS `website`,
`reply`.`created` AS `reply_created`,
`reply`.`message` AS `reply_message`
FROM `entry` FROM `entry`
LEFT JOIN `reply` LEFT JOIN `reply`
ON `entry`.`entry_id` = `reply`.`entry_id` ON `entry`.`entry_id` = `reply`.`entry_id`