0

update a data in mysql, adding data to a null column of an existing row. is it possible?

i have a c# winform that has a login function that sends its data to my table in mysql. my table has 4 columns, id-username-password-message. when i register a new user it creates a new row right? then the message column becames null. then here goes what i want to achieve- to add a value on the 'message' column in the same row for my registered user. how will i do it?

6th Oct 2019, 2:58 AM
zekrom
zekrom - avatar
3 odpowiedzi
+ 2
Why are you mixing up user information with the 'message' here. What is the relevance of the 'message' field with a user info?
6th Oct 2019, 5:02 AM
Ipang
+ 1
you can create dafault value with DEFAULT keyword https://dev.mysql.com/doc/refman/8.0/en/data-type-defaults.html
6th Oct 2019, 3:43 AM
Taste
Taste - avatar
+ 1
If you want to change your existing data: update your_table set message='default message' where message is null; if you want to set up a default value for new rows that will be insterted in the future: alter table your_table alter message set default 'default_message';
6th Oct 2019, 3:53 AM
Tibor Santa
Tibor Santa - avatar