Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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.

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;");

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
267 views
Welcome To Ask or Share your Answers For Others

1 Answer

Most likely, you accidentally put in a period:

LIMIT 0.5

which amounts to:

LIMIT 0,0

or

LIMIT 0

Try putting in a comma instead like

LIMIT 0,5

or simply

LIMIT 5

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...