If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > How to assign unique ID for deletion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-20-04, 17:13
nik007 nik007 is offline
Registered User
 
Join Date: Dec 2004
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 12-20-04, 22:42
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On