SQL help!!!!!!!
Hi, can someone please help me. I am creating a simple (or so I thought) complaint board, where users can fill in a complaint form and it is then posted to a web page for the administrator to act upon. The trouble is I want to allow the administrator to delete one of the messages from the complaints board at a time, and then have the deleted message sent to another "backup" database for future reference. I have managed to delete individual posts by useing;
DELETE FirstName, LastName FROM CUSTOMERS
WHERE (FirstName = ‘%%FirstNameField%%’)
Where firstNameField is a field in a form. Unfortunately it does not allow me to do this useing a number, which would be much better. I am useing Frontpage 2000 for ease at the moment, to allow me to learn, but am planning to move to Dreamweaver UltraDev eventually. Any help on the sql statements requierd for these two operations would be VERY MUCH appreciated!!! Thanx....
Peter J. Boettcher posted this at 18:41 — 20th March 2001.
They have: 812 posts
Joined: Feb 2000
moto,
You definitely should NOT be deleting records by First name, as you know many people have the same first name
Modify the table so it has an identity field, or a unique identifier. Then delete by using this field instead.
PJ | Are we there yet?
pjboettcher.com
moto posted this at 00:57 — 21st March 2001.
They have: 2 posts
Joined: Mar 2001
Yea, I know - just learning! What I really want to do, though, is be able to input the records unique identifier which then prevents the record from being shown on the web page. This allows the administrator to have access to records in the future...
Peter J. Boettcher posted this at 02:56 — 21st March 2001.
They have: 812 posts
Joined: Feb 2000
Ok, just wanted to make sure. Is this SQL statement in an ASP page? I'm just wondering what's with the %%, you don't need to use those unless you're using LIKE.
Try this:
DELETE FROM CUSTOMERS
WHERE IdentityField = 'PassedValue'
Just replace IdentityField with the column in your table which represents the number of the record you want to delete. PassedValue is the value you're passing to the select statement.
PJ | Are we there yet?
pjboettcher.com
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.