MySQL TOP Problem | TOP vs LIMIT

MySQL SQL TOP Problem Error - TOP VS LIMIT

mysql top problem limit

Error problem on MySQL on SQL TOP function

We are currently on the migration of our database from microsoft access to MySQL platform. The thing is, all of the TOP function that we had used before is giving an error after converting our database on MySQL.

Only later I found out that MySQL doesn't recognize the TOP function on its query, rather MySQL uses the LIMIT command function instead of the TOP.

That would mean that I need to change all of the codes on all of the pages on all of our projects. It's a little headache but I had accepted that there is really nothing I can do about it. I really need to change all of the codes since there are no workarounds.

That means that instead of this query:

SELECT TOP 1 column_name
FROM tbl_name
WHERE column_name=value;

it would need to be converted on this format:

SELECT column_name
FROM tbl_name
WHERE column_name=value
LIMIT 1;

It is a little troublesome doing this fix so I just control-F the string "SELECT TOP" to find all the codes that needed to be change.

0 Comments :

Post a Comment