I have a database that looks like this:
CREATE TABLE cargo (
    cargodate int unsigned NOT NULL,
    cargoname CHAR(128) NOT NULL,
    lattitude double NOT NULL,
    longitude double NOT NULL,
    user CHAR(64) NOT NULL
) type=MyISAM;
I want to make sure there are no more than 5 entries for this cargo at the same location with the same user. A user can have multiple entries as long as they are in different locations (lattitude, longitude).
How do I make my sql INSERT statement take care of this?
Right now I execute:
   INSERT INTO cargo VALUES (UNIX_TIMESTAMP(), '{$cargoname}', '{$lat}', '{$lng}', '{$user}');
I can do a DELETE FROM, but I want to only delete entries if there are more than 5. In that case I want to delete the oldest entries
Thanks Deshawnt