Just checking - Deleting A Whole Record

Results 1 to 6 of 6

Thread: Just checking - Deleting A Whole Record

  1. #1
    Michael DeLong Guest

    Default Just checking - Deleting A Whole Record

    If you want to delete a whole record and not just the value of one column name, you&#039;d use something like this, right?:<BR><BR>sql="Delete * FROM Wherever Where Blah = &#039;Duh&#039;"<BR><BR>Right?<BR><BR><BR>Thanks,< BR><BR>-Michael

  2. #2
    Join Date
    Dec 1969

    Default Yes, but...

    ...that *could* delete more than one record.<BR><BR>It will delete *ALL* records where the value of the given field matches the specified value. If you want to ensure that you are deleting only one record, it is best to use the field that is the primary key of the records, since no duplicates are allowed in such a field.<BR><BR>

  3. #3
    Reggie Guest

    Default A couple things

    I don&#039;t think you use * in DELETE, just do DELETE FROM WHEREVER... You might end up deleting more than one record. Consider you have only two choices for the Blah field and you have 1000 records. About half of the will be true for Blah=&#039;Duh&#039; so it will erase around 500 of them.

  4. #4
    Join Date
    Dec 1969

    Default Not quite!

    The * is optional. It really doesn&#039;t matter at all whether it is there or not. It makes zero impact on the effects of the operation. Period.<BR><BR>And Reggie is right about it possibly deleting more than one record, but the * (or lack of the *) will *NOT* change that one tiny iota.<BR><BR>

  5. #5
    Sreedharan Guest

    Default RE: Not quite! No, no.NO!

    The * is NOT optional.<BR><BR>You will get a syntax error if you use DELETE * FROM TABLENAME.<BR>

  6. #6
    Join Date
    Dec 1969

    Default Access: Optional. MySQL: not allowed!

    Maybe in some DB&#039;s the * is disallowed; it certainly can&#039;t be used with MySQL, for example. But the Access docs are quite clear that it is optional. And I *know* that I have used Access with the *.<BR><BR>Access even allows<BR><BR>DELETE foo.* FROM foo WHERE ...<BR><BR>with the table name available as a prefix.<BR><BR>In fact, if you use the QueryWizard inside Access and put in a query that omits the *, then Access puts it in for you! No choice!<BR><BR>So...consult the docs for the DB you are using.<BR><BR>But it does seem safe to always leave it out.<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts