Solved

SQL Query Help Needed

Posted on 2013-01-31
4
314 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
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
David Kroll earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.‚Äč
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

746 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

9 Experts available now in Live!

Get 1:1 Help Now