Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySql Query Help

Status
Not open for further replies.

mcox05

Programmer
Apr 25, 2006
25
US
I'm not very proficient with Mysql query strings ... so to make this simple I wanna know if it's possible to search with the following conditions and produce the correct results each time.

lets say i have a txtbox that a user can user to type in a name of something. Thin when they search the textbx's text field is used as part of the query ... simple enough.

now how do i make it more user friendly such that because i'm using someone elses Db and cannot modify it ... many entries in the database table will have underscores instead of spaces ... sometimes randomly with a pound symbol at the beginning ... some examples:

1. "#Matthew_Cox"
2. "a_Name_Record"
3. "#a_name_record2"
4. "matthew_cox"

now how do I do a query search that will bring up all the correct results (ignore case) without doing a ton of static string manipulation on the text entered by the user?

let's say the user types in "matthew cox"

I want the query to return items 1 & 4 ... is this possible using the built-in functionality of MySql querying?
 
Code:
where tablefield like concat('%',replace('matthew cox',' ','%'),'%')

by the way, this should really have been posted in forum436

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top