Solved

How to delete records from a table in pure SQL?

Posted on 2013-01-21
6
305 Views
Last Modified: 2013-01-21
I have been playing around with the insert statement in my SQL, i looked at my table and noticed that i have got 8 records for one person and 8 records for another person both of whom i used the insert statement for numerous times, obviously i only want one record for each person.

I tried to use logic, and tried DELETE * FROM Person WHERE FirstName = 'Jack Lumsdon'

&

                                             DELETE * FROM Person WHERE FirstName IS =('Jack Lumsdon')

But to no avail. I get a red squiggly line underneath the * and the error message Incorrect syntax '*'.

Any ideas of how i can get my table to delete these and bring me back down to just one record for each person.

Thanks!
0
Comment
Question by:SuperJinx
6 Comments
 
LVL 12

Expert Comment

by:mwochnick
ID: 38802666
try DELETE FROM Person WHERE FirstName = 'Jack Lumsdon'
0
 

Author Comment

by:SuperJinx
ID: 38802679
No joy! in the message's also says 0 records affected
0
 
LVL 5

Accepted Solution

by:
RehanYousaf earned 100 total points
ID: 38802713
Can you show some sample records for table PERSON and also the schema

I think what you want is to compare firstname and lastname fields

DELETE FROM Person 
WHERE FirstName = 'Jack' and LastName = 'Lumsdon'

Open in new window

0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 
LVL 8

Expert Comment

by:virtuadept
ID: 38802721
Your example has a first and a last name in the quotes.  Is the table splitting name up into two columns perhaps and you need to specifiy FirstName = 'Jack' AND LastName = 'Lumsdon' in your WHERE clause?
0
 

Author Closing Comment

by:SuperJinx
ID: 38802806
Nice one dude, that sorted it out for me!
Cheers!
0
 
LVL 12

Expert Comment

by:mwochnick
ID: 38802819
to display the table structure execute a describe statement on the person table

describe person
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now