Solved

How to delete records from a table in pure SQL?

Posted on 2013-01-21
6
306 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sql query 34 35
How to Install SSIS without the SQL Server CD 3 46
SQL Server CASE .. WHEN .. IN statement - Syntax issue 4 51
Managing Columnstore Indexes 2 18
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 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

22 Experts available now in Live!

Get 1:1 Help Now