My case is, when someone is posting to my news web data with 600k records,
they can create the same title which someone just posted in the last few hours with same subject.
data: sid|title|desc|timestamp|userid
Usually I use:
select sid from ".$prefix."_stories WHERE title = '".$subject."' limit 0,1
It searches all data for $subject then notice poster if have they have the same title.
I need a query which searches in the last 100 records.
I tried the following, but this did not work:
select sid from ".$prefix."_stories WHERE title = '".$subject."' and sid > MAX(sid)-100 limit 0,1
Assuming that you have a primary key, incrementing by 1 with every record (which will put newest at the bottom), just do this:
This will select the last 100 records
Good point by Michael in my comments… Edit to code and further comment:
Removing the where clause, this will select the last 100 records… Run a loop to check to see if the title or summary already exists:
Just compare the resulting data. Thanks Michael