Forum Moderators: coopster & phranque

Message Too Old, No Replies

MySQL - Deleting Query Help

needed please...

         

Nick_W

8:45 am on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




DELETE FROM posts,postcontrols WHERE postcontrols.postid='33' AND postcontrols.postid = posts.id

So, what's wrong with that? I just can't seem to find why I get an error trying to run the above query.

Would someone kindly point out the error of my ways? ;-)

Nick

jpjones

8:51 am on May 21, 2003 (gmt 0)

10+ Year Member



Hi Nick,
Just a guess - what data type is
postcontrols.postid
? If its an ID, i'm guessing it should be an integer.

Try removing the single quotes from around the value, e.g.
postcontrols.postid=33.
Values enclosed in single quotes are treated as strings, and a string!= integer!

HTH,
JP

DaveN

8:51 am on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nick whats the error.

try remove '' from '33'?

Dave

Nick_W

9:00 am on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm... actually it looks like you can't JOIN on a delete query?

If I change the first bit from DELETE FROM to SELECT COUNT(*) I get a result....

PS... I know about the integer thing, that's not it though ;-)

Nick

jpjones

9:04 am on May 21, 2003 (gmt 0)

10+ Year Member



I've just spotted another possible error -
What version of MySQL do you have? The ability to select records to delete across multiple tables was only introduced in version 4.

See here [informit.com] for more info.

JP

Nick_W

9:05 am on May 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ahhh.. that'll be it then! Thanks...

I'm v3.23 i think, oh well seperate deletes is no biggie..

Cheers guys, much obliged

Nick