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!

Searching through emails - the @ returns none

Status
Not open for further replies.

markphsd

Programmer
Jun 24, 2002
758
US
When i try to search a column in my database that contains emails, i can't get the query results i want if there is an @ symbol entered in the text box.

Anyone know the solution? Thanks

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
access db, but i'll be moving it to sql server shortly. (so if that will make a difference, let me know please)

very simple select statement, works for other querys without the @ symbol

SELECT ContactFirstName, ContactLastName, ContactName, ContactEmail, ContactPhone
FROM Contacts
WHERE ContactEmail like '%#form.search#%'

email is an access text
access db is setup in coldfusion with unicode

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
Hmmm, there's no reason why that SELECT statement wouldn't work. Is there an actual record with ContactFirstName, ContactLastName, ContactName, ContactEmail, ContactPhone associated with the ContactEmail? In other words, are you sure the recordcount is not 0?

I'm assuming you're not getting any errors as well, right?

Ty removing the % as a test and see if that returns any results.

____________________________________
Just Imagine.
 
I can do the same search by shorting the search phrase and get results.

"mark" returns restults. "mark@" does not.

the search works in a query in access.

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
Sorry, I should have provided an example. Here it is:

SELECT ContactFirstName, ContactLastName, ContactName, ContactEmail, ContactPhone
FROM Contacts
WHERE ContactEmail like <cfqueryparam CFSQLType="CF_SQL_VARCHAR" Value="%#form.search#%">

This metho should double as a protection against SQL injection.
 
i thought about useing a queryparameter, but i didn't see how it would make a difference, i know it's being defined as a string.

Mark P.
Providing Low Cost Powerful Point of Sale Solutions.
 
If you are going to be moving this to a SQL db, I wouldnt drive yourself mad over this. You should try little tweaks, but your original code should work on SQL. As i have never used ans Access DB, I can only speculate that either the @ or the % may be reserved in Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top