Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL statment to Delete a row

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joe Pluta
Ranch Hand
Posts: 1376
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic