[solved] Datasource filtering on optional Number Field - return entry if value not set
This is an open discussion with 2 replies, filed under General.
Search
Further to the above, since it seems it doesn't have this functionality, can anyone suggest how the SQL query in the number field could be appended to include the null values?
For example, the X to Y filter uses:
$joins .= " LEFT JOIN `sym_entries_data_$field_id` AS `t$field_id` ON (`e`.`id` = `t$field_id`.entry_id) "; $where .= " AND `t$field_id`.`value` BETWEEN {$match[1]} AND {$match[2]} ";
I tried appending "OR t$field_id
.value
IS NULL" to $where, but that produced odd results and exposed my poor knowledge of SQL.
I've already updated it to handle when the url parameter isn't set, but this is I think beyond me, so any ideas would be much appreciated.
Thanks, Fish
Excuse the talking to myself here, but in case anyone else happens upon a similar issue, bracketing the condition was the solution. E.g.:
AND ( t$field_id
.value
< $match[3] OR t$field_id
.entry_id IS NULL)
Create an account or sign in to comment.
I'm trying to filter a datasource on a number field, but I'm running into trouble with the syntax. The field is optional, and I want any results where it's not set to be returned anyway. The following works if the value is set:
However, it doesn't return the empty value entries. Is there a syntax for 'or null', something like
greater than {$url-number}, ''
Any Suggestions?
Thanks, Fish
EDIT: Sorry - I should have done more searching before posting. I see NULL filtering has been discussed before.