views:

39

answers:

3
DELETE FROM Books INNER JOIN (Classes, Class_Books) ON (Books.ISBN = Class_Books.ISBN AND Class_Books.Class_ID = Classes.Class_ID AND Classes.Term_ID = 63) WHERE Year = '""'

Gives Error: #1064 - You have an error in your SQL syntax;

Replacing DELETE with SELECT it works fine though

+1  A: 

In SQL, you say

DELETE FROM

not

DELETE * FROM

even though it's

SELECT * FROM
codersarepeople
thank you, fixed it
babonk
by "it' i mean the question.. error still there
babonk
+1  A: 
DELETE FROM Books 
WHERE ISBN IN (Select Class_Books.ISBN from Class_Books, Classes
               WHERE Class_Books.Class_ID = Classes.Class_ID 
                 AND Classes.Term_ID = 63
              )
AND Year = '""'
Michael Pakhantsov
This query times out for some reason, even though replacing DELETE with SELECT * it doesnt..
babonk
@babonk, does subquery also times out?
Michael Pakhantsov
Subquery times out
babonk
Actually it looks like the whole query is timing out now.. so I'm going to figure the general problem out then reply
babonk
was a server problem. your query works, as does the other one.. i'm going to have to accept the other just because it matches my request, but i upvoted you
babonk
A: 

Try the following, which will delete records in books that have a Classes.Term_ID = 63.

DELETE b FROM Books b
    INNER JOIN Class_Books cb ON b.ISBN = cb.ISBN
    INNER JOIN Classes c ON cb.Class_ID = c.Class_ID  
WHERE Year = '""' 
  AND c.Term_ID = 63
ar
This query times out for someone reason (replacing DELETE with SELECT * it does not though)
babonk
Actually it looks like the whole query is timing out now.. so I'm going to figure the general problem out then reply..
babonk