Re: if statment in ORDER BY
Ok, i guess what you really mean is "Normally, NULLS appear at the top in an ASC ORDER BY, and I want them to appear at the bottom, how do i do that?"
I know some SQL dialects have a syntax construct to control NULL sorting, ex Oracle. There you could say:
ORDER BY A, B NULLS LAST, C
I dont think MySQL has this. You can work around it if you know the logical maximum value for a particular column, you could use that in the IFNULL function. So, assume your B column is a INT UNSIGNED, than, the logical maximum is 4294967295 + 1. That is, 4294967295 is the maximum for a INT UNSIGNED,
So, ORDER BY A,IFNULL(B,4294967296),C would give you the desired result.
Of course, this workaround is not rigourous, there can be cases where you cannot have constant bigger than logical maximum of you column. For example, The INT UNSIGNED example would fail if it had been a BIGINT.