MySQL和PHP-如何仅显示前五行? [英] MySQL and PHP - how to display only the first five rows?

查看:424
本文介绍了MySQL和PHP-如何仅显示前五行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,我正在成功查询该数据库以显示其中一个字段的值等于x的所有行.我现在要做的是仅显示符合该条件的前5条记录.

I have a database that I am successfully querying to display all rows where the value of one field equals x. What I need to do now is ONLY display the first 5 records that meet that criteria.

到目前为止,这是我的SQL查询:

Here is my sql query so far:

$result = mysql_query("SELECT Player, Team, Pass_Yds, Pass_TDs, Int_Thrown, Rush_Yds, Rush_TDs, Overall_Pts, Total_Fantasy_Pts FROM ff_projections WHERE Position = 'QB' ORDER BY Pass_Yds DESC;");

我尝试在查询中添加LIMIT 0,5(在DESC之后但在';'之前),但是它根本不显示任何内容.

I tried adding LIMIT 0,5 to the query (after DESC but before the ';') but then it wouldn't display anything at all.

推荐答案

很可能是您不小心放入了句点:

Most likely, you accidentally put in a period:

LIMIT 0.5

等于:

LIMIT 0,0

LIMIT 0

尝试用逗号代替

LIMIT 0,5

或者简单地

LIMIT 5

这篇关于MySQL和PHP-如何仅显示前五行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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