Solved

mysql delete some alphabet from record

Posted on 2010-11-24
5
422 Views
Last Modified: 2012-05-10
How can i delete some title from colum b

Mr.David   change to  David
MissSusan  Change to  Susan
0
Comment
Question by:teera
5 Comments
 

Author Comment

by:teera
ID: 34210719
hi expert
  Miss or Mr   or Mrs must be in the first  if somepeople name  samrart  it should not elete mr from his name
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34210721
update table TableName set b = 'David' where b = 'Mr.David';
update table TableName set b = 'Susan' where b = 'MissSusan';
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 34210730
I presume you want this:

UPDATE yourtable SET b = SUBSTRING(b, 4, 1000)
  WHERE b LIKE 'Mr.%';
UPDATE yourtable SET b = SUBSTRING(b, 4, 1000)
  WHERE b LIKE 'Mr %';
UPDATE yourtable SET b = SUBSTRING(b, 5, 1000)
  WHERE b LIKE 'Miss%';

Open in new window

0
 

Author Comment

by:teera
ID: 34210734
Hi jimyX

  some people they nor name David
0
 
LVL 7

Assisted Solution

by:mkobrin
mkobrin earned 250 total points
ID: 34210769
UPDATE yourtable SET b = SUBSTRING(b, 4,)
  WHERE b LIKE 'Mr.%';
UPDATE yourtable SET b = SUBSTRING(b, 4)
  WHERE b LIKE 'Mr %';
UPDATE yourtable SET b = SUBSTRING(b, 5)
  WHERE b LIKE 'Miss%';
UPDATE yourtable SET b = SUBSTRING(b, 4)
  WHERE b LIKE 'Mrs%';
UPDATE yourtable SET b = SUBSTRING(b, 5)
  WHERE b LIKE 'Mrs.%';
UPDATE yourtable SET b = SUBSTRING(b, 6)
  WHERE b LIKE 'Miss.%';





0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Email Header Detail 12 64
Need help how to find where my error is in UFD 6 40
Format Data Field - SQL 11 37
Using cfstoredproc to return query data 2 30
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question