It looks to me like he is trying to find the row where table.date_field
is equal to the maximum of table.exit_data
. There is a check for null which I think would happen in any of these cases:
table
is empty
- all rows in
table
have exit_data
set to NULL
table.date_field
is NULL
for the row in question
In any of these three cases, the row will be returned. I don't understand why he uses the string '1=1'
instead of, to give some examples: 1=1
, 1
or true
, but it appears to work fine. In the first case I assume that there will be no rows in the result set anyway (depending on the rest of the query) so he was probably trying to handle one of the other two cases - I'd guess the last one.
This is only an explanation of what is happening. To understand why he is doing this, it would help if you gave a little more context.