Need help with a WHERE statement

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Need help with a WHERE statement

    Hi, I am working on a search page passing a variable to a master detail page.
    The SQL works fine and shows the correct variable in the debug on the page but
    it will not return the records using this variable. The SQL works as it should
    when I cut and past in into SQLyog and run the query returning all of the
    records requested. When I remove the WHERE statement all of the DB records
    show up on the master detail page correctly. So I am baffled. I am on CF 7,
    mySQL 4.1.

    Here is the query:
    SELECT make, model, veh_year, ext_color, int_color, primary_image_path,
    mileage, price
    FROM saa.vehicle_ad
    WHERE make = '#FORM.make#'
    ORDER BY price ASC

    Here is the SQL from the debug:

    SELECT make, model, veh_year, ext_color, int_color, primary_image_path,
    mileage, price
    FROM saa.vehicle_ad
    WHERE make = 'Honda'
    ORDER BY price ASC

    Any help would be great, thanks in advance.

    Shane

    Shane930 Guest

  2. Similar Questions and Discussions

    1. If Statement???
      guys i was wondering if anybody here could help me. I have a page done up with all dynamic text and attributes on it that come from a management...
    2. Use of FOR statement
      I am reading through a book on Objects and References and I don't understand this statement: $sum += $_ for split //; I thought a FOR...
    3. AW: if-else-statement
      --On Wednesday, September 03, 2003 11:56 PM +0200 "B. Fongo" <mygrps@fongo.de> wrote: Look at the docs for CGI.pm under pragmas, the -nosticky...
    4. if statement
      I'm trying to write an if statement i have two field, Status and Attendance. "status" value can be active or inactive "Attendance" value is active...
    5. IIF statement
      Assuming the data is being entered via a form, then use the AfterUpdate event of the control that is bound to the signature field. The code you need...
  3. #2

    Default Re: Need help with a WHERE statement

    2 possibilities:

    1. turn on debuggin to view actual submitted SQL, perhaps Form.make is not
    coming through ok.
    2. DataSource setting in the Administrator is pointing to a different
    database than what you expect.

    JMGibson3 Guest

  4. #3

    Default Re: Need help with a WHERE statement

    JM, thanks for the quick reply. The debug is on and that is the second select
    in the above entry. I shows that the #FORM.make is changed to 'Honda' as I
    selected this on the search form. When the WHERE statement is removed I get
    all of the records returned on the detail page. So I know the datasource is
    correct. This is not making sense to me at all.

    Thanks

    Shane

    Shane930 Guest

  5. #4

    Default Re: Need help with a WHERE statement

    Could you have a case sensitivity issue? I know with my Oracle database, I have
    to match the case of the data in the column with the value in the query, so you
    may need to do the same with your particular instance. Or, are you sure that
    there is a row where equals ?Honda??

    SELECT make, model, veh_year, ext_color, int_color, primary_image_path,
    mileage, price
    FROM saa.vehicle_ad
    WHERE LOWER(make) = '#lcase(FORM.make)#'
    ORDER BY price ASC

    or

    SELECT make, model, veh_year, ext_color, int_color, primary_image_path,
    mileage, price
    FROM saa.vehicle_ad
    WHERE LCASE(make) = '#LCASE(FORM.make)#'
    ORDER BY price ASC

    Phil

    paross1 Guest

  6. #5

    Default Re: Need help with a WHERE statement

    Well I found that the table I was using in mySQL was some how corrupt so I
    dropped it and rebuilt a new one and the page works as planned. Thanks to Dan
    and George for their input. Now on to my next challenge!

    Shane

    Shane930 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139