Terminiating a MYSQL Statement
Mysql statements executed within a php script can have 3 different endings.
$command= “Select col1, col2 from tablename where id>’0′”;
$command= “Select col1, col2 from tablename where id>’0′ “;
$command= “Select col1, col2 from tablename where id>’0′;”;
At first glance you may think they all yield the same results, but, technically, they are all different. If you want to use the queries above, they will all give the same results, unless you add another clause to the query.
However, you may want to add more length to the query like adding a limit clause; such as the one below.
$command .= ‘limit ‘ .($page_number – 1) * $number_entries .’,’ .$number_entries;
If you want to add to the initial command, it is safe to use option b since the white space at the end of the query could be the method for which the query behaves as you want it to.
Option a could merge the two statements to something like where id>’0’limit………
You do not want the end of the query to merge next to the limit clause without a space. It could cause an error.
You want where id>’0′ limit…
Option c, which ends ;”; will stop the query at the first semi-colon. Using it is fine, just remember it can lock the statement.