14

We recently switched a database from MSSQL to MySQL and the queries that use parameters don't work anymore.

Here's an example of a query in MSSQL:

SELECT * FROM users u WHERE u.ID = :id

Normally, the parameter browser would popup and ask me for a value for :id, but in MySQL I get the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':id'

I tried using a @ or ? instead of : and those do not work either.

1
  • Is this SELECT used in a stored precedure? Commented Sep 6, 2011 at 18:43

1 Answer 1

40

syntax is not the same

set @id:=123;
SELECT * FROM users u WHERE u.ID = @id;

Docs for User defined variables

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.