What does SELECT ~0; do? I've recently stumbled into an interesting Mysql query:

SELECT ~0;
results:
18446744073709551615

Which is the max value of a bigint unsigned. What does the tilde operator do in this case?
It selects the logical negation of 0 and returns it in the implicitly converted datatype.  Rather than selecting 8 bytes containing all 0's, it selects 8 bytes containing all 1's, returning the maximum possible unsigned value.