?
Solved

SQL Query Help Needed

Posted on 2013-01-31
4
Medium Priority
?
328 Views
Last Modified: 2013-01-31
I have a MySQL database names FLOW. I have a table in this DB named INFO. In this table I have several fields but I need a SQL that I can run to check filed fname, mname, and lname for hyphens (-), periods (.), apostrophes ('), and commas (,) & if possible trailing blank spaces. Can someone help me out on this? Thanks
0
Comment
Question by:wantabe2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
David Kroll earned 2000 total points
ID: 38840707
update INFO
set fname = ltrim(rtrim(fname)),
mname = ltrim(rtrim(mname)),
lname = ltrim(rtrim(lname))

update INFO
set fname = replace(fname, '-', ''),
mname = replace(mname, '-', ''),
lname = replace(lname, '-', '')

update INFO
set fname = replace(fname, '.', ''),
mname = replace(mname, '.', ''),
lname = replace(lname, '.', '')

update INFO
set fname = replace(fname, ',', ''),
mname = replace(mname, ',', ''),
lname = replace(lname, ',', '')

update INFO
set fname = replace(fname, '''', ''),
mname = replace(mname, '''', ''),
lname = replace(lname, '''', '')
0
 
LVL 15

Author Comment

by:wantabe2
ID: 38840717
does that SQL just check for them & give me the results or does it actually find them & then get rid of them?
0
 
LVL 11

Expert Comment

by:David Kroll
ID: 38840731
gets rid of them.
0
 
LVL 15

Author Comment

by:wantabe2
ID: 38840737
awesome! Thanks!
0

Featured Post

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

765 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