Solved

Access SQL Query to Delete records based on Condition

Posted on 2015-02-24
5
168 Views
Last Modified: 2015-02-24
I have a table that needs to be dedicated to just one customer. However, the records do not have the customer names listed like I would like. I need to delete some records based on a condition that is one of the fields.

Table Name: DSCNSKPIUPDATE
Field Name: Reject

Condition: R0*

So In my field "Reject" I have several different formats of text. However, I only want to keep the records that start with "R0".

** The records have back up copies for the other customers **

The text look like these...
R0117730
R0116926
R0118216
or
N/A
20140903436
2014070323
1
To be released

As you can see there are many different formats. I need to remove all records that do not start with "R0".
0
Comment
Question by:ggodwin
  • 3
  • 2
5 Comments
 
LVL 59

Accepted Solution

by:
Saurabh Singh Teotia earned 500 total points
ID: 40628129
You can use this query..

I'm assuming you are using this in access:-

Delete * from  DSCNSKPIUPDATE
where left(Reject,2)<>"RO" 

Open in new window


Change the RO one in single quotes if you are working in SQL and remove * from the same...

Saurabh...
0
 

Author Closing Comment

by:ggodwin
ID: 40628143
Worked perfectly
0
 

Author Comment

by:ggodwin
ID: 40628150
If the field "Reject" is NULL can I use this?

Delete * from DSCNSKPIUPDATE
Where Reject is NULL

Open in new window

0
 
LVL 59

Expert Comment

by:Saurabh Singh Teotia
ID: 40628184
Yeah that should be taken care of as the left,2 is not RO but you can use this...

Delete * from  DSCNSKPIUPDATE
where left(Reject,2)<>"RO"  or reject is null

Open in new window


This will do that...

Saurabh...
0
 

Author Comment

by:ggodwin
ID: 40628215
Thank you. For what ever reason it did not get covered in the Left,2
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

746 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

13 Experts available now in Live!

Get 1:1 Help Now