This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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.
 
Don't get me started about those stupid light bulbs.
 
subject: SQL statment to Delete a row
 
Similar Threads
SQLException error: "Invalid Cursor position"
what is the return value of executeUpdate statement to create a table?
problem in updating a row in JDBC
SQL statement to Delete a row
Change and delete rows in a sql-database