Skip to main content
April 27, 2006
Answered

Query Problem??

I'm working with flash remoting and I'm having a bit of trouble. If I pass a param to my coldfusion document as a number and it's a defined number in the database the query works great. I can't get it to work properly if I'm checking for matching text not numbers. Can anyone help me with what I'm doing wrong? Here's my CF document code:

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Correct answer
    April 28, 2006
    Okay, thanks everyone for your help. Everything works great now, I'm going to switch to mysql before I get too far.... thanks again!

    6 replies

    Correct answer
    April 28, 2006
    Okay, thanks everyone for your help. Everything works great now, I'm going to switch to mysql before I get too far.... thanks again!
    Translate
    Participating Frequently
    April 27, 2006
    Add single quotes:
    WHERE username = '#userID# '
    Translate
    Inspiring
    April 27, 2006
    If username is a char or varchar datatype, you need single quotes around #userid# in the where clause of your query.

    If it is numeric, you have to do something to ensure that the userid variable is always numeric.

    Or it might just be a logic problem.
    where username = #userid#
    looks a little suspicious.
    Translate
    Participating Frequently
    April 27, 2006
    What database are you using? You may have a case sensitivity issue., or you could have leading/trailing spaces problem causing you not to match as well. You can use the various TRIM functions to get rid of the space issue, and you can use one of the various case functions to remove the case issue.

    For an Oracle database, you might do something like this:

    <cfquery name="userDetailQuery" datasource="testDataBase">
    SELECT *
    FROM users
    WHERE UPPER(username) = ‘#TRIM(Ucase(userID))#’
    </cfquery>

    You get the idea.

    Phil
    Translate
    April 27, 2006
    would this be the same for a access database? i'm just trying to make sure it all works and then i'll switch to a mySQL database.
    Translate
    Inspiring
    April 28, 2006
    quote:

    Originally posted by: C-Rock
    would this be the same for a access database? i'm just trying to make sure it all works and then i'll switch to a mySQL database.

    There is a significant disadvantage to that plan. Different dbs have different functions, or different syntax for the same function. If you plan to finish with mySql, you should start with mySql.
    Translate