MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 3rd, 2009, 04:34 PM
fubes2000's Avatar
fubes2000 fubes2000 is offline
manwich
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canadanistan
Posts: 372 fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Days 8 h 22 m 38 sec
Reputation Power: 236
Odd error between SELECT and DELETE

Over the last day or so one of our applications has gone haywire in conjunction with an MS exchange problem and flooded the database with excess attachments. [about 5GB worth] The application itself can't delete everything before running out of memory, I whipped up a query to remove the entries. The problem is that mySQL does not seem to be parsing through the whole query when I run the delete.

A simple count query to test runs fine:
Code:
SELECT COUNT(*)
FROM swticketposts po INNER JOIN swattachments att
	ON po.ticketpostid = att.ticketpostid
	INNER JOIN swattachmentchunks ch
	ON att.attachmentid = ch.attachmentid
WHERE po.ticketid = 221404
	AND po.ticketpostid != 439145;
and returns 228277.

A quick change to DELETE, like so:
Code:
DELETE
FROM swticketposts po INNER JOIN swattachments att
	ON po.ticketpostid = att.ticketpostid
	INNER JOIN swattachmentchunks ch
	ON att.attachmentid = ch.attachmentid
WHERE po.ticketid = 221404
	AND po.ticketpostid != 439145;
yields the error
Quote:
/* SQL Error: 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 'INNER JOIN swattachments att ON po.ticketpostid = at */

I've tried backquoting the table aliases and ecapsulating the JOIN conditions in parentheses but it seems like the query is just being truncated after a certain number of characters, even when running it from the CLI.

Any ideas what's going on here?

Edit: almost forgot, version 5.0.37-log
__________________

Last edited by fubes2000 : July 3rd, 2009 at 04:40 PM.

Reply With Quote
  #2  
Old July 3rd, 2009, 04:52 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 20,687 r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Week 3 Days 9 h 27 m 54 sec
Reputation Power: 2458
Quote:
Originally Posted by fubes2000
Any ideas what's going on here?
yup... bad syntax

your multi-table DELETE looks like SQL Server

try the MySQL syntax...

DELETE x FROM x INNER JOIN y ...

check da manual for further examples

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #3  
Old July 3rd, 2009, 05:00 PM
fubes2000's Avatar
fubes2000 fubes2000 is offline
manwich
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canadanistan
Posts: 372 fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)fubes2000 User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1Folding Points: 154682 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Days 8 h 22 m 38 sec
Reputation Power: 236
orz I was reading from the manual, I was just reading it wrong.

Yeah, depending which hat I'm currently wearing I have to switch between MSSQL and mySQL a few times a day so everything just blurs together.

Thanks r937!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Odd error between SELECT and DELETE


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
Stay green...Green IT