Update id field after deleting from database

cfuser_n used Ask the Experts™
thanks gueys its working fine now
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
COUNT(id) is an aggregate function, it returns only one row containing the number of ID's found in the DB in your case. Looping from 1 to the count is going to get you a loop from 1 to 1.

What you want to do is to renumber the IDs correct? This can be done in one statement like so, rather than looping:

SET ID = ID - 1
WHERE ID > #Form.Q_Num#
Hi paresh,
I am a bit confused on what exactly u wish to do here

since ur query is "UPDATE FAQ SET ID='#i#'" - this is obviously update all records u ahve in the tbale as there is no where condition in it.

what u need to do is specify the where clause & then things willbe fine for u

but i wonder on what grounds r u gonna specify the where clause ... cos i cldnt get much from the q's u posted above

let me know

cfuser_n, please don't remove the original question when you edit the question. Either add a comment, or add to the original text.

Another person with a similar problem may have been able to find this question and find the solution on their own. Now it is very unclear as to what the issue is.

If you have resolved the issue on your own, you should post your solution so that others can benefit. If you have used experts code to resolve your problem, then select the comment that was most helpful as the accepted answer. This will help close the issue out.

yap totally agree to tallermike !

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial