Solved

SQL Query Help Needed

Posted on 2013-01-31
4
325 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 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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

739 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