?
Solved

mysql delete some alphabet from record

Posted on 2010-11-24
5
Medium Priority
?
437 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 1000 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

807 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