Solved

Delete query syntax help

Posted on 2011-03-01
12
242 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 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
ID: 35011701
try the query i posted.
0
 

Author Comment

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

Expert Comment

by:Rey Obrero
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 119

Expert Comment

by:Rey Obrero
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 119

Expert Comment

by:Rey Obrero
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 40

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

760 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

18 Experts available now in Live!

Get 1:1 Help Now