473,787 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting with LEFT JOIN=>How to?

Hello,

DB-structure:
=========
firmendaten
-----------------
firmendatenid <-
firmennummer
name
strasse
hausnr

platzierungen
-----------------
platzierungenid
platzierungswor t
platzierungsfol ge
firmendatenid <-
Questions:
==========
1.) I would like to find the records from the table 'positioning' that
are not joined with 'companydata'. I did this as following, is that
correct?

SELECT a.platzierungen id, a.platzierungsw ort, a.firmendatenid ,
b.firmendatenid
FROM platzierungen a
LEFT JOIN firmendaten b ON b.firmendatenid = a.firmendatenid
WHERE b.firmendatenid IS NULL

2.) Now I want to delete just these found records, in the table
'platzierungen' that don't have a equivalent record in the table
'firmendaten', since the company does not existent anymore.

MySQL 4.0.20:
-----------------

DELETE FROM platzierungen LEFT JOIN firmendaten ON
firmendaten.fir mendatenid = platzierungen.f irmendatenid WHERE
firmendaten.fir mendatenid IS NULL

MySQL error output:

#1064 - You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'LEFT JOIN firmendaten ON firmendaten.fir mendatenid = platzieru

=> What am I doing wrong? How do I transfer above SELECT statement to
a DELETE Statement?

Thanks for your help!
Jul 20 '05 #1
2 1526
R. Tarazi wrote:
Hello,

DB-structure:
=========
firmendaten
-----------------
firmendatenid <-
firmennummer
name
strasse
hausnr

platzierungen
-----------------
platzierungenid
platzierungswor t
platzierungsfol ge
firmendatenid <-
Questions:
==========
1.) I would like to find the records from the table 'positioning' that
are not joined with 'companydata'. I did this as following, is that
correct?

SELECT a.platzierungen id, a.platzierungsw ort, a.firmendatenid ,
b.firmendatenid
FROM platzierungen a
LEFT JOIN firmendaten b ON b.firmendatenid = a.firmendatenid
WHERE b.firmendatenid IS NULL

2.) Now I want to delete just these found records, in the table
'platzierungen' that don't have a equivalent record in the table
'firmendaten', since the company does not existent anymore.

MySQL 4.0.20:
-----------------

DELETE FROM platzierungen LEFT JOIN firmendaten ON
firmendaten.fir mendatenid = platzierungen.f irmendatenid WHERE
firmendaten.fir mendatenid IS NULL

MySQL error output:

#1064 - You have an error in your SQL syntax. Check the manual that
corresponds to your MySQL server version for the right syntax to use
near 'LEFT JOIN firmendaten ON firmendaten.fir mendatenid = platzieru

=> What am I doing wrong? How do I transfer above SELECT statement to
a DELETE Statement?

Thanks for your help!


This article should help you:
http://www.electrictoolbox.com/artic...-table-delete/

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 20 '05 #2
> SELECT a.platzierungen id, a.platzierungsw ort, a.firmendatenid ,
b.firmendatenid
FROM platzierungen a
LEFT JOIN firmendaten b ON b.firmendatenid = a.firmendatenid
WHERE b.firmendatenid IS NULL
DELETE FROM platzierungen LEFT JOIN firmendaten ON
firmendaten.fir mendatenid = platzierungen.f irmendatenid WHERE
firmendaten.fir mendatenid IS NULL


what about this:

Delete From platzierungen
SELECT a.platzierungen id, a.platzierungsw ort, a.firmendatenid ,
b.firmendatenid
FROM platzierungen a
LEFT JOIN firmendaten b ON b.firmendatenid = a.firmendatenid
WHERE b.firmendatenid IS NULL
HP
Jul 20 '05 #3

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

Similar topics

8
2343
by: Arvid Andersson | last post by:
Hello, I need to convert a string to a number, but the string can contain +,-,* and / as well as parenthesis. For example, if I have the string "30/(6+9)" I would like a function that returned the number 2. I actually wrote a java function that did this a couple of years ago, in school, as an excersise in "binary trees". I lost it, and most of my programming knowledge, but I figured perhaps there is a way to do this easily in python? It...
0
1820
by: Federico Moschini [328594] | last post by:
I have to make difference between2 data from a table in SQL. The page is made with Frontpage, and it extracts QtaGiaCons and Quantita from table "oclrighe". I have to make Quantita - QtaGiaCons to obtain QtaInev (quantity that I have to ship because I have partially shipped) I wait for your suggestion. Thank you.
2
1777
by: R. Tarazi | last post by:
Hello, DB-structure: ========= firmendaten ----------------- firmendatenid <- firmennummer name strasse
2
7942
by: Bart Plessers \(artabel\) | last post by:
Hello, I need a style that defines -table cellspacing -table cellpading -alignment I tried <table class="TBLpageframe"> <tr class="TRpageframe">
2
9269
by: Jonathan Taub | last post by:
This may seem a stupid question. I've got a <textarea> element: .... <td> List of items: <textarea> 1. Apple 2. Orange 3. Box
12
2403
by: Kevin Blount | last post by:
I'm playing with dragable <DIV>s, being inspired by google.com/ig, where you can move items on the page around and have items you move over change position if necessary. I have 3 div's setup, one for each dragable item (boxes about 100x150px), inside another div that sets up a border. my script is instigated by an onMouseOver event and works great for moving items, setting the opacity, etc. The only trouble is (and I guess I should...
3
2744
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have reports at the plan (overall totals), department and division levels which have sorting and grouping implemented with this new
6
5516
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp; DataBinder.Eval(Container.DataItem,"StoreEmail") &amp; "&amp;Subject=" &amp; DataBinder.Eval(Container.DataItem,"ProductName") ....
11
8187
by: dtinsley | last post by:
Ok, I have having a problem joing these two queries. Can anyone please help me out here. These are the results of my two queries: These are the values in the A1 field of QueryA COCKBURN 2 GT KW 1 GTN 1 IPP GT1 IPP GT2 KALG F5
3
2458
by: Tobi Hammert | last post by:
i have a page that shows a random picture, centered. how do i create a layer that stays centered, but always 300 px down from the top? to make it clear again: i want to place a text layer, x=centered, y=300. is it even possible, or do layers have get absolute positions?
0
10363
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...
1
10110
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
9964
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
8993
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
7517
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
5398
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...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.