Limit help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lukevrn
Forum Newbie
Posts: 3
Joined: Mon Feb 09, 2009 2:30 pm

Limit help

Post 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 !
User avatar
Frozenlight777
Forum Commoner
Posts: 75
Joined: Wed May 28, 2008 12:59 pm

Re: Limit help

Post by Frozenlight777 »

Code: Select all

$sql5="SELECT * FROM clan_matches WHERE Clan_Fought_Cheated = 'Yes' LIMIT 0, 5";
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Limit help

Post 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.
Post Reply