Solved

MySQL Delete records

Posted on 2011-09-08
6
249 Views
Last Modified: 2012-05-12
I have a table called TableA that has a column called 'status' .  I need to delete all records where in the table that do not match a status of A-Active or AC-Active.

Can someone give me the proper MySQL command to do this?
0
Comment
Question by:pda4me
6 Comments
 
LVL 8

Accepted Solution

by:
pilson66 earned 250 total points
ID: 36502128
delete from TableA where status != 'A-Active' and status != 'AC-Active';
0
 
LVL 8

Expert Comment

by:pilson66
ID: 36502133
0
 
LVL 8

Expert Comment

by:pilson66
ID: 36502142
delete from TableA where status not in ('A-Active', 'AC-Active');
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 4

Expert Comment

by:veera
ID: 36502154
DELETE FROM TableA WHERE Status != 'A-Active' OR Status != 'AC-Active'
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36502163
delete from TableA where status not in ('A', 'AC');
0
 
LVL 27

Assisted Solution

by:yodercm
yodercm earned 250 total points
ID: 36502185
BE CAREFUL:

delete from TableA where status != 'A-Active' and status != 'AC-Active';    is CORRECT



DELETE FROM TableA WHERE Status != 'A-Active' OR Status != 'AC-Active'   WILL DELETE EVERYTHING
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

679 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