473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Delete query syntax trouble

TheSmileyCoder
2,322 Expert Mod 2GB
I have a table tbl_Dialog:
KEY_Dialog, ID_Obs .....

Table tbl_Obs
KEY_Obs, ID_Review .....

They are linked by KEY_Obs and ID_Obs, and I want to delete all records in tbl_Dialog having ID_Review=1200.

I tried:
Expand|Select|Wrap|Line Numbers
  1. myDB.Execute "DELETE tbl_Dialog.* FROM tbl_Dialog INNER JOIN tbl_Obs ON (tbl_Dialog.ID_Obs=tbl_Obs.KEY_Obs) " & _
  2.          '            " WHERE (((tbl_Obs.ID_Review) In " & listRelatedReviews(lngRevID) & ") AND (tbl_Dialog.dt_Date=" & formatSQLdate(dtSubmittal) & "));"
ListRelatedReviews will return a string containing other relevant Review IDs, in this case the string returned would be "(1200,472)"

My problem is that instead of only deleting the records in tbl_Dialog, the code also deleted the records in tbl_Obs.

What should I change to only delete the records from tbl_Dialog?
Jun 22 '12 #1

✓ answered by Rabbit

Take out the join and filter using a subquery in the where clause.

3 1493
Rabbit
12,516 Expert Mod 8TB
Take out the join and filter using a subquery in the where clause.
Jun 22 '12 #2
dsatino
393 256MB
You may have a relationship between the fields with a cascading deletion.
Jun 22 '12 #3
NeoPa
32,556 Expert Mod 16PB
I suggest you post the actual SQL code run, rather than the code which creates it - which doesn't appear to match the comments in the post as it stands.

As it stands, the syntax appears to be correct, but there's no filtering in this version so ...
Jun 25 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: r | last post by:
I am trying to do a delete query like this one: DELETE FROM pending WHERE pages.url=pending.url AND pages.date=pending.date; If I run it (via PHP) I get the following error: Unknown table...
6
by: Saiyan Vejita | last post by:
I have the following SELECT query, the results of which I would delete from the table they're pulled from: SELECT A.* FROM SalesOrderPartPrices A WHERE EXISTS( SELECT 'Exists' FROM...
2
by: Joe Del Medico | last post by:
I have two tables A & B and I want to delete all the records in A that are not in B. Can I do this in the query builder? It seems like a simple problem. I can easily find the records in A that...
1
by: Mark Reed | last post by:
Hi All, I have a table with a date field and 6 number fields. The number fields are not in numerical order across the fields and I want number 1 to be the lowest number and number 6 to be the...
6
by: Mark Reed | last post by:
Hi all, Please help. I have a table with 2 fields of which I am trying to change a select query into a delete query. the select query is: SELECT Table1.Date, Min(Table1.Ball) AS MinOfBall...
2
by: Dalan | last post by:
Having searched the archives regarding a Delete Query, I found nothing specific to my need, although there seems to be a plethora of ideas and suggestions on queries in general. I have used Delete...
1
by: Thompson Yip | last post by:
The following delete query: DoCmd.RunSQL "delete * from where ='" & strInput & "'" and DoCmd.RunSQL "delete from where ='" & strInput & "'" Are they equivalent in term of functionality?
13
by: forbes | last post by:
Hi, I have a user that used the Query Wizard to create a query in Access. Now she claims that her master table is missing all the data that was excluded from the query. Can you create anything...
3
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get...
3
by: rbukkara | last post by:
Hi guys, I have some trouble with the following query. Please look into this and lemme know the solution ASAP. It certainly involves aggregations and the 'having clause' BROKER( ID integer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.