Remove last chars

Thread Solved

Join Date: Jan 2009
Posts: 105
Reputation: jen140 is an unknown quantity at this point 
Solved Threads: 5
jen140 jen140 is offline Offline
Junior Poster

Remove last chars

 
0
  #1
18 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 105
Reputation: jen140 is an unknown quantity at this point 
Solved Threads: 5
jen140 jen140 is offline Offline
Junior Poster
 
0
  #2
17 Days Ago
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");
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,736
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 328
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster
 
-1
  #3
17 Days Ago
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!
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 105
Reputation: jen140 is an unknown quantity at this point 
Solved Threads: 5
jen140 jen140 is offline Offline
Junior Poster
 
0
  #4
17 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,736
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 328
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster
 
-1
  #5
17 Days Ago
Cool ! Congrats
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC