Solved

SQL Query Help Needed

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

820 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