Jump to content

Deleting related entries in multiple tables


missyevil

Recommended Posts

Hi, this is probably a really simple problem, but I can't seem to get the syntax for the command right!

I'm trying to delete related entries in 2 MySQL tables simultaneously. What I'm trying looks like this:

[code]DELETE FROM cvs, jscvs WHERE cvid = '$cvid'[/code]

Where cvs and jscvs are the two tables, and cvid is the primary key in each.

When I run it tho, I get an error, and nothing is deleted.

Any ideas?
This could work as well

it will delete every key that has a matching one in the other table...leaving the 'unrelated' ones
as I assume you wanted

[code]
DELETE FROM cvs, jscvs USING cvs, jscvs WHERE cvs.id = jscvs.id;[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.