Solved

How to delete records from a table in pure SQL?

Posted on 2013-01-21
6
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
In this article I will describe the Detach & Attach 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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

628 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