Solved

SQL Query Help Needed

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql query to calculate avaerage 21 40
two ways encryption with php 3 28
sql server tables from access 18 19
Complex SQL statement in VB.NET 7 15
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
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
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

810 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