943,991 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Marked Solved
  • Views: 1396
  • MySQL RSS
Nov 3rd, 2009
0

Remove last chars

Expand Post »
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 <b>b</b>lol");
insert into abc(2,"bye <b>a</b>lol");
i would like to remove 3 last characters or the string "lol".
Thanks in advance.
Have a good day.
Similar Threads
Reputation Points: 11
Solved Threads: 6
Junior Poster
jen140 is offline Offline
116 posts
since Jan 2009
Nov 4th, 2009
0
Re: Remove last chars
Dont know why cant i edit the post,
but the querrys arent right, they should be :
insert into abc(id,text) values(1,"hello <b>b</b>lol");
insert into abc(id,text) values(2,"bye <b>a</b>lol");
Reputation Points: 11
Solved Threads: 6
Junior Poster
jen140 is offline Offline
116 posts
since Jan 2009
Nov 5th, 2009
-1
Re: Remove last chars
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!
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
Nov 5th, 2009
0
Re: Remove last chars
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.
Reputation Points: 11
Solved Threads: 6
Junior Poster
jen140 is offline Offline
116 posts
since Jan 2009
Nov 5th, 2009
-1
Re: Remove last chars
Cool ! Congrats
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

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.
Message:
Previous Thread in MySQL Forum Timeline: What does mysql return when the selection doesnt exist?
Next Thread in MySQL Forum Timeline: exclude





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC