如何编写(MySQL)"LIMIT"在SQL Server中? [英] How to write a (MySQL) "LIMIT" in SQL Server?

查看:77
本文介绍了如何编写(MySQL)"LIMIT"在SQL Server中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试将带有LIMIT的查询从MYSQL更改为SQL Server时,我遇到了问题.

I have a problem when i try to change a query with LIMIT from MYSQL to SQL-Server.

检查:

SELECT * 
FROM tableEating 
WHERE person = '$identity' 
LIMIT 1;

我尝试通过一些查询来更改它,但是没有任何效果.

I tried to change it with some queries but nothing work.

推荐答案

LIMIT在T-SQL中不起作用.

LIMIT does not work in T-SQL.

您必须改为使用TOP,例如:

You have to use TOP instead, like this:

SELECT TOP(1) * FROM tableEating WHERE person='$identity';

我希望这对您有用.

正如亚伦所说,如果您不想获得任意行,还需要一个ORDER BY.

As Aaron says, you also need an ORDER BY if you don't want to get an arbitrary row.

这篇关于如何编写(MySQL)"LIMIT"在SQL Server中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆