Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Posts
    1

    Unanswered: How to assign unique ID for deletion

    Hi,

    I am a MySQl-PhP beginner, and I have a question regarding the deletion query.

    I have a table with fields:


    first name, last name and full name.


    Field Type Null Key Default Extra
    -------- ------- ------ ------ ------- ------
    id int(5) PRI 0
    First Name text YES (NULL)
    Last Name text YES (NULL)
    Full Name text YES (NULL)

    I want to delete the record after checking/sorting using last name.

    My query for that case is:

    "DELETE from db WHERE LastName='$LastName' ";

    Now suppose, there are more than one records with the last name "Jones"; it deletes all of 'em.

    How do I ensure that I delete just ONE particular record with the last name "Jones"?

    Any pointers/URLs to read/suggestions would be welcome.

    Thanks all.

    --nik

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by nik007
    Now suppose, there are more than one records with the last name "Jones"; it deletes all of 'em.

    How do I ensure that I delete just ONE particular record with the last name "Jones"?
    which Jones row do you want to delete? how do you distinguish it from the other Jones rows?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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