Solved

Delete query syntax help

Posted on 2011-03-01
12
274 Views
Last Modified: 2012-06-22
Need help getting this to work

DELETE  clss_tbl_Temp_Oracle_Download.*
FROM TestCritLike, clss_tbl_Temp_Oracle_Download
WHERE (((clss_tbl_Temp_Oracle_Download.PRIME) Like [TestCritLike].[First Prime Like]));
0
Comment
Question by:Keking
  • 6
  • 5
12 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35011555
are you getting any error when running the query?

how does the content of field PRIME compared to the field [First Prime Like]

post sample data..

 try this

DELETE  clss_tbl_Temp_Oracle_Download.*
FROM clss_tbl_Temp_Oracle_Download,TestCritLike
WHERE (((clss_tbl_Temp_Oracle_Download.PRIME) Like [TestCritLike].[First Prime Like]));

or


DELETE  clss_tbl_Temp_Oracle_Download.*
FROM clss_tbl_Temp_Oracle_Download,TestCritLike
WHERE Instr([clss_tbl_Temp_Oracle_Download].[PRIME], [TestCritLike].[First Prime Like]) >0


0
 

Author Comment

by:Keking
ID: 35011659
I am getting, could not delete from Specified Tables. I have an append query that works but now I need to delete the same data from the table after I append it.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35011701
try the query i posted.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:Keking
ID: 35011720
I tried both and am still getting the same error.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35011730
can you upload a copy of the db
0
 

Author Comment

by:Keking
ID: 35011745
It is with a SQL back end and I am not able to upload any data.
0
 

Author Comment

by:Keking
ID: 35011757
here is the append that works. i am trying to delete all that appends from the temp table

INSERT INTO TestTable ( [Period Number], [Period Year], [Period Name], COMPANY, [Company Description], DIVISION, [Division Description], BASIS, [Basis Description], PRIME, [Prime Description], SUB, [Subaccount Description], LOB, [Lob Description], PRODUCT, [Product Description], [COST CENTER], [Cost Center Description], AFFILIATE, [Affiliate Description], [RISK INDICATOR], [Risk Description], NETWORK, [Network Description], [SERVICE TYPE], [Serv Type Description], [FACILITY LOCATION], [Facility Description], PTD_Activity, GLCategory, TestCAT )
SELECT clss_tbl_Temp_Oracle_Download.[Period Number], clss_tbl_Temp_Oracle_Download.[Period Year], clss_tbl_Temp_Oracle_Download.[Period Name], clss_tbl_Temp_Oracle_Download.COMPANY, clss_tbl_Temp_Oracle_Download.[Company Description], clss_tbl_Temp_Oracle_Download.DIVISION, clss_tbl_Temp_Oracle_Download.[Division Description], clss_tbl_Temp_Oracle_Download.BASIS, clss_tbl_Temp_Oracle_Download.[Basis Description], clss_tbl_Temp_Oracle_Download.PRIME, clss_tbl_Temp_Oracle_Download.[Prime Description], clss_tbl_Temp_Oracle_Download.SUB, clss_tbl_Temp_Oracle_Download.[Subaccount Description], clss_tbl_Temp_Oracle_Download.LOB, clss_tbl_Temp_Oracle_Download.[Lob Description], clss_tbl_Temp_Oracle_Download.PRODUCT, clss_tbl_Temp_Oracle_Download.[Product Description], clss_tbl_Temp_Oracle_Download.[COST CENTER], clss_tbl_Temp_Oracle_Download.[Cost Center Description], clss_tbl_Temp_Oracle_Download.AFFILIATE, clss_tbl_Temp_Oracle_Download.[Affiliate Description], clss_tbl_Temp_Oracle_Download.[RISK INDICATOR], clss_tbl_Temp_Oracle_Download.[Risk Description], clss_tbl_Temp_Oracle_Download.NETWORK, clss_tbl_Temp_Oracle_Download.[Network Description], clss_tbl_Temp_Oracle_Download.[SERVICE TYPE], clss_tbl_Temp_Oracle_Download.[Serv Type Description], clss_tbl_Temp_Oracle_Download.[FACILITY LOCATION], clss_tbl_Temp_Oracle_Download.[Facility Description], clss_tbl_Temp_Oracle_Download.PTD_Activity, clss_tbl_Temp_Oracle_Download.GLCategory, IIf([PRIME] Like [First Prime LIke] And [Second Facility Location]=[FACILITY LOCATION],[GLCategory True],[GLCategory False]) AS TestCAT
FROM clss_tbl_Temp_Oracle_Download, TestCritLike
WHERE (((clss_tbl_Temp_Oracle_Download.PRIME) Like [First Prime Like])) OR (((clss_tbl_Temp_Oracle_Download.[SERVICE TYPE]) Like [First Service Type Criterea]));
0
 

Author Comment

by:Keking
ID: 35012417
I think it is because there is a primary key field that is included with the .* and it cannot delete that field. Any ideas how I can get around that?
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35012532
Keking,
not sure about oracle, but in sql

you can do this using vba codes

dim dSql as string
dSql="delete *"
dsql =dsql & " FROM clss_tbl_Temp_Oracle_Download,TestCritLike"
dsql =dsql & " WHERE (((clss_tbl_Temp_Oracle_Download.PRIME) Like [TestCritLike].[First Prime Like]))"

currentdb.execute dsql, dbseechanges
0
 

Author Comment

by:Keking
ID: 35016451
That data is from Oracle but it is put into a SQL table. Putting the vba in did not work either. I get incorrect syntax near * . If I take it out I get a problem with the ,
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35016850
Keking,
click on Request Attention above and ask that the Oracle topic be added to this thread, to get more response from oracle experts
0
 
LVL 41

Accepted Solution

by:
Sharath earned 500 total points
ID: 35022948
give a try.
DELETE FROM clss_tbl_temp_oracle_download 
WHERE       EXISTS (SELECT 1 
                    FROM   testcritlike 
                    WHERE  clss_tbl_temp_oracle_download.prime LIKE [testcritlike].[first prime like]);

Open in new window

0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
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 …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

735 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