You need LIKE instead of = with wildcards

Pascal

> -----Original Message-----
> From: Daniel Kessler [mailto:[EMAIL PROTECTED]
> Sent: vrijdag 19 maart 2004 16:53
> To: CF-Talk
> Subject: unique user query
>
> I'm doing a registration test.  First I test the name and if
> it fails, I try to get the total number of userNames that
> begin with the name and suggest that as a new name (ie
> daniel87697).  Then I test to make sure that name is valid.  
> Unfortunately, the second query where I get the count doesn't
> seem to be working.  I'm using % in the WHERE, which I
> understand to be a wild-card.  My code below.
>
> <!--- check registration name--->
>
> <cfquery name="check_username" datasource="my-site">
>        SELECT *
>        FROM bodyfun_registry
>        WHERE userName = '#Form.userName#'
> </cfquery>
> <cfif check_username.recordcount gt 0>
>
>        <!--- get number of people registered with  that as
> the start of their name--->
>
>        <cfquery name="check_total_usernames" datasource="my-site">
>              SELECT *
>              FROM bodyfun_registry
>              WHERE userName = '#Form.userName#%'
>        </cfquery>
>
>         <!--- check the new suggested name--->
>
>        <cfquery name="check_new_username" datasource="my-site">
>              SELECT *
>              FROM bodyfun_registry
>              WHERE userName =
> '#Form.userName##check_total_usernames.recordcount#'
>        </cfquery>
>
>        <!--- output--->
>        <cfif check_new_username.recordcount gt 0>
>              <cfset nameError = "This name is already taken.  
> The name must be unique.">
>        <cfelse>
>              <cfset nameError = "This name is already taken.  
> The name must be unique.
> Suggestion:#Form.userName##check_total_usernames.recordcount#">
>        </cfif>
>
>        <cfset errorState = true>
> </cfif>
>
> I'm sure there's a better way to suggest a name, but this is
> an added feature so I'm doing it as well as I can do quickly.
>
> thanks.
>
> --
> Daniel Kessler
>
> Department of Public and Community Health University of
> Maryland Suite 2387 Valley Drive College Park, MD  20742-2611
> 301-405-2545 Phone
> www.phi.umd.edu
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to