473,653 Members | 2,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with delete query

r
I am trying to do a delete query like this one:

DELETE FROM pending WHERE pages.url=pendi ng.url AND
pages.date=pend ing.date;

If I run it (via PHP) I get the following error: Unknown table 'pages'
in where clause.

What I am actually trying to do is that I want to delete a record from
the table "pending" where the fields url and date (the combination) in
both tables are the same.

Both the tables pages and pending do exist.
If I look in the MySQL manual I see this example:

DELETE t1,t2 FROM t1,t2,t3 WHERE t1.id=t2.id AND t2.id=t3.id

Which looks pretty much on the query I try to do.

Does anybody see what I am doing wrong? And what I should do to make
this work?

Thanks in advance!

Wim
Jul 19 '05 #1
2 2921
r wrote:
I am trying to do a delete query like this one:

DELETE FROM pending WHERE pages.url=pendi ng.url AND
pages.date=pend ing.date;
Your query looks like this:
delete from t1 where t2.url=t1.url and t2.date=t1.date ;
DELETE t1,t2 FROM t1,t2,t3 WHERE t1.id=t2.id AND t2.id=t3.id

Which looks pretty much on the query I try to do.


No it doesn't.

This would look like the example:

delete t1,t2 from t1,t2 where t2.url=t1.url and t2.date=t1.date ;

But you propably want to delete only from the t1 table, so I think the
query would be:

delete t1 from t1,t2 where t2.url=t1.url and t2.date=t1.date ;

Don't test this with valuable material since I have never done
multitable delete queries and I'm not sure whether this removes material
from t1 or both t1 and t2. This was more like a wild quess how it should
be. I'm in a bit hurry so I don't have to test it myself now. Please
tell if it worked or not.

Jul 19 '05 #2
r wrote:
I am trying to do a delete query like this one:

DELETE FROM pending WHERE pages.url=pendi ng.url AND
pages.date=pend ing.date;
Your query looks like this:
delete from t1 where t2.url=t1.url and t2.date=t1.date ;
DELETE t1,t2 FROM t1,t2,t3 WHERE t1.id=t2.id AND t2.id=t3.id

Which looks pretty much on the query I try to do.


No it doesn't.

This would look like the example:

delete t1,t2 from t1,t2 where t2.url=t1.url and t2.date=t1.date ;

But you propably want to delete only from the t1 table, so I think the
query would be:

delete t1 from t1,t2 where t2.url=t1.url and t2.date=t1.date ;

Don't test this with valuable material since I have never done
multitable delete queries and I'm not sure whether this removes material
from t1 or both t1 and t2. This was more like a wild quess how it should
be. I'm in a bit hurry so I don't have to test it myself now. Please
tell if it worked or not.

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2229
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 highest. I have come up with the idea to create a new table with a date and number field only. I have then put all the records from the first table into the new table which has only the 2 fields. I then run an append query into a 3rd table with the...
8
25054
by: John Baker | last post by:
Hi: Access 2000 W98! I have a table with numerous records in it, and am attempting to delete certain records that have been selected from it. These are selected based on the ID number in a different table. While I am using the tools in Access for query setup, its easier to show it on here using the SQL for the query, which is as follows( the table is ): DELETE .date, .,
8
9153
by: Gox | last post by:
Hi, I got a problem with VBE6.DLL (VBA reference) On my machine everything work well.(access 2k, vesion dll 6.0.84.35) First machine NO PROBLEM (access 2003, vesion dll 6.4.99.72) Second machine problem (access xp, vesion dll 6.4.99.69) I used pivot query and function Format(, "mmm") for Column Heading This is error:
4
10626
by: Ian | last post by:
Hi, I have a problem with delete using where in clause. This is a query: delete from tab1 where id not in (select id from tab2) I calculated costs using select instead of delete: select count(*) from tab1 where id not in (select id from tab2) select count(*) from tab1 t1 left outer join tab2 t2 on t1.id = t2.id
5
9922
by: Neil | last post by:
I am getting time-out errors when I try to perform a simple delete on a linked server. The command is: Delete From MyTable Where PKID=12345 I have tried executing this command directly from Query Analyzer, but it just times out. However, when I run it from QA against the server itself (rather than from my local server against a linked server), it executes immediately. Similarly, if I run the same SQL command through an ODBC linked...
7
7184
by: alan_conoco | last post by:
Hi all, I am trying to delete a subset of records (identified using my InsertRemovePairs query) from a table names TradesDone. When I execute the nested SELECT on its own it returns the correct records. When I execute is nested in the DELETE it tries to delete everything in my database.... What have I missed??
2
2391
by: dean.cochrane | last post by:
I have inherited a large application. I have a table which contains a hierarchy, like this CREATE TABLE sample_table( sample_id int NOT NULL parent_sample_id int NOT NULL ....lots of other cols...) DELETEs on all tables are handled by the front end code, which just
3
1365
Odisey
by: Odisey | last post by:
I am not sure if this is a MySQL syntax error or a DB issue yet. I am getting the error from the code: Page Error! This page has been accessed in error. The GET is populated in the browser address window with a valid user ID, yet I get the error. I've studied this script - it should work. Any ideas? ===================================
3
2505
by: Hasse1982 | last post by:
Hi I have a table KDOCUMENT with the columns , , , , , ,
0
8370
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8283
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8590
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.