Author Topic: [SOLVED] DELETE FROM help please  (Read 637 times)

0 Members and 1 Guest are viewing this topic.

Offline sspokeTopic starter

  • Enthusiast
  • Posts: 278
    • View Profile
[SOLVED] DELETE FROM help please
« on: September 04, 2007, 10:34:06 PM »
i know how to do this now with UPDATE/SELECT's

but not im sure why it doesn't compile with DELETE FROM.

/** failures */
DELETE FROM `user_invitems` AS l USING `user_credentials` AS c WHERE l.id = c.id AND c.name = 'testing123'
DELETE FROM `user_invitems` AS l,  `user_credentials` AS c WHERE l.id = c.id AND c.name = 'testing123'
DELETE FROM `user_invitems` AS l,  `user_credentials` AS c AS l.id = c.id AND c.name = 'testing123'

using 2 tables 1 to pick name from and match its id row to a different tables row.


also another question relating speed its really odd on the working UPDATE/SELECT which is exactly like DELETE FORM except it works..
for some reason those UPDATE/SELECT process for this took around 0.0130 secs to get id from a different table and do its process which is alot more compared to normal SELECT/UPDATEs on a preset id which are like 0.0020 secs

Offline sspokeTopic starter

  • Enthusiast
  • Posts: 278
    • View Profile
Re: DELETE FROM help please
« Reply #1 on: September 04, 2007, 10:56:06 PM »
did more research and tried
DELETE `user_invitems` FROM `user_invitems` AS l, `user_credentials` AS c WHERE l.id = c.id AND c.name = 'testing123'

didn't work..

can't edit topics srry

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: DELETE FROM help please
« Reply #2 on: September 04, 2007, 11:06:58 PM »
delete from tablename where field =condition
thats all!!!!!!

Offline sspokeTopic starter

  • Enthusiast
  • Posts: 278
    • View Profile
Re: DELETE FROM help please
« Reply #3 on: September 04, 2007, 11:18:39 PM »
delete from tablename where field =condition
thats all!!!!!!

No.. I know that.. im talking about SELECT + DELETE in one DELETE.

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: DELETE FROM help please
« Reply #4 on: September 04, 2007, 11:22:24 PM »
delete from tablename where fieldtobedeleted in(select form tbale where condition)????
« Last Edit: September 04, 2007, 11:29:30 PM by teng84 »

Offline sspokeTopic starter

  • Enthusiast
  • Posts: 278
    • View Profile
Re: DELETE FROM help please
« Reply #5 on: September 04, 2007, 11:33:53 PM »
and how can I do what u said?  ??? ?

DELETE FROM `user_invitems` AS l, `user_credentials` AS c WHERE l.id = c.id IN c.name = 'testing123'
?

remember I can't delete user_invitems without only deleting the linked ID's to user_credentials by name..

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: DELETE FROM help please
« Reply #6 on: September 04, 2007, 11:41:28 PM »
do something like a Cartesian join
http://dev.mysql.com/doc/refman/5.0/en/delete.html

Offline sspokeTopic starter

  • Enthusiast
  • Posts: 278
    • View Profile
Re: DELETE FROM help please
« Reply #7 on: September 05, 2007, 03:45:45 PM »
yah thats no help..  :o at all..


Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: [SOLVED] DELETE FROM help please
« Reply #8 on: September 07, 2007, 04:10:57 PM »
yah thats no help..  :o at all..

Did you get this figured out? There was a lot of nonsense posted on this thread....
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.