Forum Moderators: coopster
I have a question about overwriting mysql fields.
Is it possible to overwrite an existing field in mysql?
Let's say I have a table name "TEST" and I have a field in there "TEXT".
If I have some text in row one of "TEXT" already, and I want to change the content of the text in row one. Is there a way to overwrite it? Or do I have to delete the whole row and rewrite the text again.
If I do have to delete the whole row, then how to delete only the middle row instead of trucating the whole table.
Regards
Opiston
Or if you don't know the id, but old text then:
UPDATE test SET text='Bla bla new text here' WHERE text='Here was old text';
However the query UPDATE updates all rows that match!
To delete any row:
DELETE FROM test WHERE id='1';
your table should have id:
CREATE TABLE test(id INT NOT NULL auto_increment, text TEXT, PRIMARY KEY(id));
BTW I'm not sure that it's ok to name the field "text" as it may be a keyword. Better rename it to
ALTER TABLE test CHANGE text my_text TEXT;
Best regards
Michal Cibor
DELETE FROM test WHERE id='1';, but it didn't work for some reason. I will try it again tonight.
As for
UPDATE test SET text='Bla bla new text here' WHERE id='1';, I didn't know such thing as UPDATE, thank you for sharing this knowledge.
I didn't name the field as text, I was using it as an example. I guess it's an bad example, and thanks for reminding.
Best Regards
Opiston