Page 1 of 1

Limit help

Posted: Mon Feb 09, 2009 2:37 pm
by lukevrn
how you make

Code: Select all

$sql5="SELECT * FROM clan_matches WHERE Clan_Fought_Cheated = 'Yes'";
show only the last 5 inserts

Thanks !

Re: Limit help

Posted: Mon Feb 09, 2009 2:43 pm
by Frozenlight777

Code: Select all

$sql5="SELECT * FROM clan_matches WHERE Clan_Fought_Cheated = 'Yes' LIMIT 0, 5";

Re: Limit help

Posted: Mon Feb 09, 2009 3:03 pm
by califdon
lukevrn wrote:how you make

Code: Select all

$sql5="SELECT * FROM clan_matches WHERE Clan_Fought_Cheated = 'Yes'";
show only the last 5 inserts

Thanks !
What does "the last 5 inserts" mean? Based on a date in the records? Based on an auto-incremented ID in the records? What? In general, relational databases and SQL operate on the theoretical assumption that there is no such thing as inherent "order" or "sequence" of rows in a table. The sequence of rows must be determined by data in those rows. You may think that that doesn't make sense, when you can open a table and SEE the sequence of rows, but that's what the theory is based on, because other operations, like deletions, or copying data to a new table, can render that inaccurate, so there's nothing in SQL that guarantees what order rows will be in unless you use the ORDER BY clause in your query.