Search code examples
mysqlauto-update

mysql column auto update issue


Here is my table columns

id----time_created----time_updated----db_user

when a row is added to this table, or any updated occurred, the db_user should auto updates to the database username who insert/modify the row


Solution

  • MySQL's USER() function will yield the username provided when connecting to the data base. You can include that in an INSERT or UPDATE statement. There's no way to do it completely automatically. You could use a trigger if you wanted it done without changing front-end code.