php - My Select top query isn't working -


this question has answer here:

can tell me wrong query? it's printing else statement, , it's giving error:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near '2 * `sql_tbl`' @ line 1.

 <?php   $con=mysqli_connect("localhost","root","","sql_db");    $sqli="select top 2 * `sql_tbl`";      $querys=mysqli_query($con,$sqli);       if($querys){    echo "query correct";}       else{        echo "query not write". mysqli_error($con);        }   ?> 

the equivalent "top" syntax in mysql "limit":

so:

  $sqli="select top 2 * `sql_tbl`"; 

becomes:

 $sqli="select * `sql_tbl` limit 2";` 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -