How to generate a "non existent value"?
I'm working on a validation that compares a POST variable (param) from a form with database values in order to avoid double entries. (it's a room reservation application where the user can book a room for the morning (value 1 for DAUERID), afternoon(2) or the whole day (3) (you can't book a morning if the whole day is already taken). The validation works as long as there is a value for the DAUERID in the table reservation table but the select statement returns no value (from the recordset) if there is no DAUERID value for the parameter to compare. So the validation fails. Here is the select statement:
SELECT DAUERID, ( CASE
WHEN param = 1 AND DAUERID = 1 THEN 1
WHEN param = 1 AND DAUERID = 3 THEN 1
WHEN param = 1 AND DAUERID = 2 THEN 0
WHEN param = 2 AND DAUERID = 1 THEN 0
WHEN param = 2 AND DAUERID = 3 THEN 1
WHEN param = 2 AND DAUERID = 2 THEN 1
WHEN param = 3 AND DAUERID = 1 THEN 1
WHEN param = 3 AND DAUERID = 2 THEN 1
WHEN param = 3 AND DAUERID = 3 THEN 1
ELSE 0
END) AS result
FROM res_reservationen
It looks like ELSE 0 is not working, means result is empty. Any ideas how to fix this problem? Thanks in advance!