Solved

mysql delete some alphabet from record

Posted on 2010-11-24
5
412 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 142

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now