I am having a challenge working with multiple documents, particularly dealing with duplicate filenames in the database. I am trying to create a system in which an admin can add HTML documents. He will input two fields: name of the document and its source code.
When adding a document, the name (e.g. "A Page") and the filename (based on the name e.g. "a_page.html") will be inserted to the database and a file with the source code inside will be created on the server.
The problem now is what happens if I try to add another document with the same name e.g. "A Page". I would like the filename to be "a_page_2.html" to not overwrite the existing one. And if another with the same name, "a_page_3.html" and so on.
Is there a simple SQL statement for achieving?