Uh, well, your query did *exactly* what you told it to do.

If you want the update to update more then just the record where CheckID =
1, then you will need to change your WHERE clause.
consider
WHERE <primary_key_field> = <somevalue>
will NEVER EVER update more then 1 record, because you are guaranteed to
only find 1 record (or no records) with specified primary key!!!
(autonumber is a primary key, presumably you are using an Access database
(Ugh))

If you want to update only records according to some rule, then, well, you
need to state that as a condition in your WHERE clause.

I recommend you take a SQL course, or head to the library and pick up an
entry level book on SQL.  SQL is very powerful, and you could benefit
greatly from learning more about it.

Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes
[EMAIL PROTECTED]


  -----Original Message-----
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Arun Persaud
  Sent: Thursday, April 18, 2002 7:14 PM
  To: [EMAIL PROTECTED]
  Subject: [CFTALKTor] Updating counter values


  I've been racking my brain for the past hour. I'm having trouble updating
the values for each record in  COLUMN 3 all at once:


  TABLE2:COLUMN 1
  CheckID (autonumber)
  1
  2
  3

  TABLE2:COLUMN 2
  Reviews  (int)
  4
  2
  7

  TABLE2:COLUMN 3
  checkReviewCount (int)
  0
  0
  0


  This is the Query that I'm using:

  <CFSET NewValue = #checkCategory.ReviewCount# + 1>

  <CFQUERY NAME="UpdateCounter" DATASOURCE="DB">
  UPDATE TABLE2
  SET ReviewCount = #NewValue#
  WHERE CheckID = #checkCategory.CheckID#
  </CFQUERY>

  The problem is that it will only add 1 to the first record and not the
others. So COLUMN 3 looks like this:

  TABLE2:COLUMN 3
  checkReviewCount (int)
  1
  0
  0

  instead of this:

  TABLE2:COLUMN 3
  checkReviewCount (int)
  1
  1
  1

  Also, if this manages to work, I need to stop the addition of 1, once the
value in "Reviews" equals the value in "checkReviewCount". (i.e. 4 = 4)

  Thanks again everyone. Gonna go soak my brain.


  Arun Persaud

<<attachment: winmail.dat>>

Reply via email to