0

I'm not an PHP expert but I'm trying to learn more. Here in my company I have a "Work Order" system based on PHP + MySQL. It works just fine but now I need to convert it to use MSSQL database. I did a lot of things and now almost all functions are working fine on MSSQL. But I have one function that I cannot figure out how to convert. That is:

public function check_username_1($username) {
  $data = $this->_db->select("SELECT tclients.Username FROM tclients WHERE tclients.Username = :username LIMIT 1", array(':username' => $username));
  return count($data);
}

If I use this function on MSSQL I get the error:

SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near 'LIMIT'.

I did some research here and found out that MSSQL doesn't suport LIMIT. Is there something I could replace it with?

1
  • There is no limit. but you can use "select top 1" if you only need 1 row Commented Aug 12, 2015 at 15:43

1 Answer 1

0

The shortest path is to simply change the select to conform to MSSQL Syntax: the MSSQL equivalent for the LIMIT 1 clause is to say SELECT TOP 1

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.