I have a table which stores "active" users of some arbitrary facility. There is an insert operation for every time a particular user logs on and logs off. What I want to be able to do is as follows:
- Upon detection of an insert operation into the database, check if the username is already present in the MYSQL database.
- If the username is present, then do not insert and delete the existing entry.
- If the username is not present, then insert.
Is there any way to achieve this? I am fairly new to MYSQL so I apologize in advance if anything I've said doesn't make sense - just ask for my clarification.