Deleting a Record
Hi, I a seting up a php page that will let me delete a record from my mysql database, but I want it be able to match to fields before it will let a user delete that record. I know the basic sql command is DELETE FROM $table WHERE field 1 = $value But I don't know how to write the state for a second field. Can some one tell, but one field seem to give too much choose and would make it to easy to delete the wrong record. | Chuck Payne | | Magi Design and Support | | [EMAIL PROTECTED] | BeOS, Macintosh 68K, Classic, and OS X, Linux Support. Web Design you can afford. Never be bullied into silence. Never allow yourself to be made a victim. Accept no one's definition of your life; define yourself.- Harvey Fierstein - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: Deleting a Record
* Chuck PUP Payne I know the basic sql command is DELETE FROM $table WHERE field 1 = $value But I don't know how to write the state for a second field. Can some one tell, but one field seem to give too much choose and would make it to easy to delete the wrong record. I think this is what you are asking for: DELETE FROM $table WHERE field1 = $value AND field2 = $value2 Very often you would want an unique key for your table, a so called PRIMARY KEY. In general, using the primary key is the safest and fastest way to delete one and only one record. -- Roger query - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Deleting a Record
At 7:46 -0500 3/6/02, Chuck \PUP\ Payne wrote: Hi, I a seting up a php page that will let me delete a record from my mysql database, but I want it be able to match to fields before it will let a user delete that record. I know the basic sql command is DELETE FROM $table WHERE field 1 = $value But I don't know how to write the state for a second field. Can some one tell, but one field seem to give too much choose and would make it to easy to delete the wrong record. Connect the conditions with AND: DELETE FROM tbl_name WHERE col1 = 'value1' AND col2 = 'value2' | Chuck Payne | | Magi Design and Support | | [EMAIL PROTECTED] | BeOS, Macintosh 68K, Classic, and OS X, Linux Support. Web Design you can afford. Never be bullied into silence. Never allow yourself to be made a victim. Accept no one's definition of your life; define yourself.- Harvey Fierstein - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: Deleting a Record
Thanks I have now five ways to try. | Chuck Payne | | Magi Design and Support | | [EMAIL PROTECTED] | -Original Message- From: Paul DuBois [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 06, 2002 10:43 AM To: Chuck PUP Payne; [EMAIL PROTECTED] Cc: PHP General Subject: Re: Deleting a Record At 7:46 -0500 3/6/02, Chuck \PUP\ Payne wrote: Hi, I a seting up a php page that will let me delete a record from my mysql database, but I want it be able to match to fields before it will let a user delete that record. I know the basic sql command is DELETE FROM $table WHERE field 1 = $value But I don't know how to write the state for a second field. Can some one tell, but one field seem to give too much choose and would make it to easy to delete the wrong record. Connect the conditions with AND: DELETE FROM tbl_name WHERE col1 = 'value1' AND col2 = 'value2' | Chuck Payne | | Magi Design and Support | | [EMAIL PROTECTED] | BeOS, Macintosh 68K, Classic, and OS X, Linux Support. Web Design you can afford. Never be bullied into silence. Never allow yourself to be made a victim. Accept no one's definition of your life; define yourself.- Harvey Fierstein - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Deleting a record
I am working on a perl application that manages a database created in Mysql. I am having trouble with the delete statement. Here is a portion of the perl code that is being executed: $dbh=DBI-connect(dbi:mysql:clientdb:localhost,web,webpassword); ### # Delete Routine # ### if ($action eq 'delete'){ $st_text = DELETE FROM client WHERE (idnumber='$submitidnumber');; print $st_text; $sth = $dbh-prepare( $st_text ) or die Could not prepare $st_text ; # Close the table. print BRH2Record $submitidnumber Deleted Successfully!/H2 br br a href='resultscompany'Back to Browse/View Screen/a BR a href='main.cgi'Back to Main Menu/a BR A HREF='http://10.0.0.3'Back to the home page/A /BODY /HTML; Note: $submitidnumber is populated elsewhere in the script. If the code is executed, no error pops up, and the query is printed on the screen: DELETE FROM client WHERE (idnumber='sho002'); but the record is not being deleted. If I copy the command to the mysql console, it does successfully delete the record. Bye the way, other queries--select and update are working from the perl scripts. Help please. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail mysql-unsubscribe-##L=##[EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: re: deleting a record
At 06:18 AM 2/23/2002 +0100, you wrote: Your message cannot be posted because it appears to be either spam or simply off topic to our filter. To bypass the filter you must include one of the following words in your message: sql,query If you just reply to this message, and include the entire text of it in the reply, your reply will go through. However, you should first review the text of the message to make sure it has something to do with MySQL. Just typing the word MySQL once will be sufficient, for example. You have written the following: Sorry to bother everybody. I now see that I just needed to put the execute statement in. This is what I get for doing a database web programming at midnight. - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Deleting a record
On Sat, 23 Feb 2002, Jon Shorie wrote: I am working on a perl application that manages a database created in Mysql. I am having trouble with the delete statement. Here is a portion of the perl code that is being executed: $dbh=DBI-connect(dbi:mysql:clientdb:localhost,web,webpassword); ### # Delete Routine # ### if ($action eq 'delete'){ $st_text = DELETE FROM client WHERE (idnumber='$submitidnumber');; print $st_text; $sth = $dbh-prepare( $st_text ) or die Could not prepare $st_text ; You've prepared the statement, but you haven't executed it. You need $sth-execute; here. # Close the table. print BRH2Record $submitidnumber Deleted Successfully!/H2 br br a href='resultscompany'Back to Browse/View Screen/a BR a href='main.cgi'Back to Main Menu/a BR A HREF='http://10.0.0.3'Back to the home page/A /BODY /HTML; Note: $submitidnumber is populated elsewhere in the script. If the code is executed, no error pops up, and the query is printed on the screen: DELETE FROM client WHERE (idnumber='sho002'); but the record is not being deleted. If I copy the command to the mysql console, it does successfully delete the record. Bye the way, other queries--select and update are working from the perl scripts. Help please. Michael Stassen University Information Technology Services Indiana University Bloomington [EMAIL PROTECTED] - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail mysql-unsubscribe-##L=##[EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php