Hello all.
I have a small db, that has news.
I want to update the field "content" to add the phraze " Aproved by Admin" for every row in the database.
A better explanation, i have table news, with 1 table that is defined : create table news (id int, creator char(10), content char(255));
and for example i have 2 rows:
insert into news values (1,"admin","test1");
insert into news values (1,"nonadmin","test2");
i want to update all the values of the content be current content+" Aproved by Admin"
How can i do that ?
Thanks in advance.
I want to update the field "content" to add the phraze " Aproved by Admin" for every row in the database.
How can i do that ?
Thanks in advance.
You can run an UPDATE query that updates a field relative to itself, as an example "UPDATE tbl SET tblfield = tblfield + 1" With no qualifiers, this will make every value for tblfield in that table 1 larger than it was before.
You don't say what database you're using, but you would want string concatenate functions. Assuming MySQL your query would be:
UPDATE news SET content = concat(content, ' Approved by Admin'
And that's it. Keep in mind that with no qualifiers (i.e. "WHERE category = 'approved'" or whatever) it will update *all* fields. If that's what you want, you're done.
This is my first post here. If I get formatting wrong I apologize.
Thanks for your response ,but i am using mysql ,as shown in the middle :
DaniWeb Community > Web Development > Databases > MySQL
And wellcome to the board =)
Thanks for your response ,but i am using mysql ,as shown in the middle :
DaniWeb Community > Web Development > Databases > MySQL
And wellcome to the board =)