473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Removing Non Alpha Characters before saving?

17
i have a table that lets say has 3 fields
ID, NAME, SEARCHFIELD
name can take any character, while searchfield only has the alpha/num characters from name. (eg name: Swine-?6$Man Searchfield:Swine6Man)

is there a way i could do this by just passing in the name to a stored procedure?

the reason im doing this, is if a user wants to search a database with only know the word/numerical values he knows. i couldnt think of another way, and im not good at sql. I was thinking of having it on the .net backend, but id like to keep on the DB side.

Thank you guys!
Nov 14 '08 #1
8 3945
Atli
5,058 Expert 4TB
Hi.

You could use the LIKE clause to search using wild-cards.

For example, if you had a string like "Swine-?654Man", and you wanted a search for "Swine Man" to match that, you could simply convert the space into a wild-card (%) and execute a query like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT fields FROM table WHERE field LIKE 'Swine%Man'
  2.  
Nov 16 '08 #2
Betray
17
but see the poroblem with that is, when the user wants to do a search with out the fields it wont find it.
Database: Swine-?654Man
Users Search: SwineMan

it wont return any results. Unless there is a way to ignore characters in a MSSQL search.


For a temporary soloution, i created another field that has the user name with out any special characters. and thats what it searches against.
Original Field: Swine-?654Man
Searchable Field: SwineMan

Redundent data, i know. But i cant think of another soloution at this time.
Nov 18 '08 #3
r035198x
13,262 8TB
1.) Are you using MySQL or MSSQL?
2.) What did you say is the reason for the SEARCHFIELD column?
Nov 18 '08 #4
Betray
17
im using mssql, i created that field, so there is a searchable field
username: Froggy^Man
Search field: FroggyMan

Users Search: Froggy^Man

what i do is ignore special characters, and search the searchfield for the match.
Nov 19 '08 #5
r035198x
13,262 8TB
im using mssql, i created that field, so there is a searchable field
username: Froggy^Man
Search field: FroggyMan

Users Search: Froggy^Man

what i do is ignore special characters, and search the searchfield for the match.
Well you posted this in MySQL != MSSQL.
I have to say this special characters business is all very strange to me. What do you need those special characters for and where are they coming from.

P.S Moved to MSSQL forum.
Nov 20 '08 #6
Betray
17
Well you posted this in MySQL != MSSQL.
I have to say this special characters business is all very strange to me. What do you need those special characters for and where are they coming from.

P.S Moved to MSSQL forum.
thank you for moving it! Sorry about the confusion.

The Special characters are used for a product key. I guess i should explained it that way so there is a better understanding.
so lets say here is a product code: /HR/U39S03-33
now if a user wanted to do a search for that product id, but he only had the alpha/numeric characters, it would never pull it up. "HRU39S0333", so i created that search field, so that it only hold HRU39S0333. and if a user did a partial search, HRU39, it would find it, becauise i have LIKE %usersinput%. id like to get rid of that extra field, and extra data, and something less maintenance.
if there was some kinda of MSSQL command that could ignore those characters when doing the select statement with the "like" result.

hope this is a better description. Thank you pros!
Nov 20 '08 #7
r035198x
13,262 8TB
Couldn't you could still just use one field to store the code with those characters and then call some replace function on the database value when comparing with the user's input?
Nov 20 '08 #8
ck9663
2,878 Expert 2GB
It would be easier to parse the string on the front-end.

-- CK
Nov 21 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: success_ny | last post by:
Does anyone have a code snippet to compare those values so I can sort the array of alpha-numeric values that include both characters and integers in it? I.e., if we have values like 4236 and...
6
by: Mark C | last post by:
All, Is there such a function that can strip all non alpha ( not between a-z) characters from a string? I have a function that I currently use that will strip one character at a time from a...
1
by: Barry Gilmore | last post by:
I have a multi-line entry box that the users can enter text. Is there a way I can strip out the return characters before saving it to the database? Thank you!
18
by: Andrew Christiansen | last post by:
Hey all. The images I create in photoshop with semi-transparent pixels (for instance in Photoshop text with a dropshadow with a transparent canvas) I've been saving in PNG format and then using...
2
by: Brian Henry | last post by:
Is there any quick and easy (other then scanning a string char by char) to remove all the alpha chars from a string and leave only numbers? ex: A12334234-3431AP comes out to 123342343431...
1
by: ad | last post by:
From the past posted, I know char c = (char)rnd.Next('a', 'z' + 1); can generate a alpha randomly. But now I want to generate a alpha or a digit randomly. ('0'..'9' or 'a'..'z') How can I...
8
by: .Net Sports | last post by:
I am checking for text input on a form validation in javascript that required at least one numeric character along with any number of alpha characters for a given input text box. The below is a var...
3
by: Patrick A | last post by:
I want to add a character to some fields I want to "push" to the end of an alpha sort. Anyone know what characters I can use? Thanks, Patrick
5
lotus18
by: lotus18 | last post by:
Hello World! I have a sample code here written in vb .net that restricts the textbox to accept only alpha, alphanumeric or numeric characters. Public Enum MyOption Alpha = 1 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.