Hello all.
I have a small db, that has news.
I want to update the field "content" to add the phraze "<br>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:
I want to update the field "content" to add the phraze "<br>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, '<br> 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 =)
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.