954,116 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Remove last chars

Hello all, i would like to know how it is possible to remove for example last 20 characters, or by specifing the string to remove.
For example i have 2 rows (in reality there are more than 100, thats why im not working it out by hand) with the next content:
insert into abc (1,"hello blol");
insert into abc(2,"bye alol");
i would like to remove 3 last characters or the string "lol".
Thanks in advance.
Have a good day.

jen140
Junior Poster
117 posts since Jan 2009
Reputation Points: 11
Solved Threads: 6
 

Dont know why cant i edit the post,
but the querrys arent right, they should be :
insert into abc(id,text) values(1,"hello blol");
insert into abc(id,text) values(2,"bye alol");

jen140
Junior Poster
117 posts since Jan 2009
Reputation Points: 11
Solved Threads: 6
 

Hi, can you elaborate your question ?
If you are inserting the value to the table from php, you can use substr to insert only a part of a string. If you are directly inserting the record to the table, you can use mysql's substring function.
If this solves your problem, well and good.. If it doesn't, please explain your question in detail.
P.S you can only edit your post within 30 mins of posting! :)

Cheers!

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

Thanks for response, i've found what i was looking for, and it was mysql's replace function =).
What i neded to do was to remove part of the data in a row that repeated itself once for a row and many times for a column.
so i just neded to use next:
update abc set text=replace(text,'lol','NOTLOL') where 1;
and it would do what i neded.

jen140
Junior Poster
117 posts since Jan 2009
Reputation Points: 11
Solved Threads: 6
 

Cool ! Congrats :)

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You