473,772 Members | 3,148 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 1776
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

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
1526
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">
12
2402
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
2743
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
2
2502
by: beetle | last post by:
Hello, I'm storing data in several different binary tree's. The root node is located in a struct containing general data about the tree. struct lnode { char *fname; int nentry;
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") ....
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?
1
3483
by: pavithraj | last post by:
i m getting error. its not at all inserting into database.showing error like as below Notice: Undefined index: franchise_hours in E:\wamp\www\franchasebazaar\admin_template\action\add_indian_franchisor.php on line 29 Notice: Undefined index: investment in E:\wamp\www\franchasebazaar\admin_template\action\add_indian_franchisor.php on line 36 Notice: Undefined index: franchise_hours in...
0
10261
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
10104
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
10038
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
9912
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
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.