1

I have used limit and offset in the past for pagination, but now I am getting a HY000 error when trying to run it. Removing "LIMIT 30" returns all 10,000 rows with no problem. Using PDO (pdo_mysql v. 5.5.50), and PHP 5.5.9.

PHP

$stmt = $this->con->prepare("SELECT * FROM taxon LIMIT 30");
if(!$stmt->execute()){
     print_r($stmt->errorInfo());
}

Result:

Array
(
    [0] => HY000
    [1] => 102
    [2] => General SQL Server error: Check messages from the SQL Server [102] (severity 15) [(null)]
    [3] => -1
    [4] => 15
)

EDIT: My issue was that after moving to MYSQL recently, I was still pointing to my old MSSQL database. Solved.

aceslowman
  • 611
  • 11
  • 26
  • 4
    According to your error message, you're using `SQL Server`, not `mysql`, and `SQL Server` does not have `LIMIT`. http://stackoverflow.com/questions/603724/how-to-implement-limit-with-microsoft-sql-server – aynber Aug 08 '16 at 17:19
  • I'm puzzled why it seems many Microsoft SQL Server users think they're using MySQL. This comes up frequently. – Bill Karwin Aug 08 '16 at 17:23
  • In my case I just recently migrated from SQL Server to MySQL, apparently forgot to change dblib to mysql when setting up my connection. Thank you for catching this simple mistake. – aceslowman Aug 08 '16 at 17:27
  • you can't use limit with sql server, use top and rownumber for that – Quijote Shin Aug 08 '16 at 17:40

0 Answers0