The secret of 1>0
Hi all,
You might seen some MySQL statement likes below:
$sql="SELECT * FROM table WHERE 1>0";
Alright, so, what's the usage or secret behind of 1>0?
It's actually used when we have to check other condition after MySQL statement above, so our SQL statement will be likes below:
if($user!='') $sql.=" AND user='".$user."'";
So, 1>0 is actually used to enforce the SQL statement to be executed, as TRUE AND TRUE results TRUE.
- Forums:
