Get username/account name from email address
Client table contains first name, last name, email, and department. I need to compare the username portion of the email address (that is, everything before @) to the session's username to verify authenticity.
How may I structure my cfquery to compare the desire portion of the email address to the session variable casuser?
<cfquery name="getUsername" dsn="myDSN">
select firstname, lastname, email, department, organiz开发者_StackOverflowation, rank
from client
where email= '#casuser#'
</cfquery>
The database is on SQL Server 2008 using CF8.
Thanks.
Pretty much you need to use like statement and compare anything including @ sign. So should be something similar to this:
select firstname, lastname, email, department, organization, rank
from client
where email like '#casuser#@%'
There's obviously nothing wrong with Andrey's approach, but in the event you'd rather not use the like...
email = getToken(casUser,1,"@");
Definitely include cfqueryparam
精彩评论