I am having trouble finding documentation about this specific statement
SELECT IF (count(f.id)=0,1,0) as flgNew
FROM table f ON ...
It's basically the same as the following
SELECT CASE WHEN count(f.id) = 0 THEN 1 ELSE 0 END AS flgNew ...
It checks to see if the expression
count(f.id) = 0 is true, and returns the value
1 if it is, and
0 if it is not.
You can read more on the
IF() function in the official docs here: