aspose file tools*
The moose likes JDBC and the fly likes SQL statment to Delete a row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL statment to Delete a row " Watch "SQL statment to Delete a row " New topic
Author

SQL statment to Delete a row

Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hello,
Could you please tell me how to delete a row in a database.
I am asking for the SQl statement. for example "INSERt INTO" for inserting values.
Thanks


SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Joe Pluta
Ranch Hand

Joined: Jun 23, 2003
Posts: 1376
DELETE FROM MYTABLE WHERE FIELD = 'SOMEVALUE'
The WHERE clause can be as complex as you want. Just be careful; if your WHERE clause is incorrect, you may delete records you did not intend to delete. In fact, if you leave the WHERE clause off completely DELETE will delete all the rows in the table.
Joe
Darren Bell
Greenhorn

Joined: Aug 01, 2003
Posts: 14
Also, if you are deleting single rows, it's best to use all the primary key fields in the where clause. This gaurantees that only a single row will be deleted.
 
Consider Paul's rocket mass heater.
 
subject: SQL statment to Delete a row