0

I need to create a join that will delete the entries in two tables. The delete will happen in projects when the project_id in the table is equal to the one on the page of the php document. I need the link entries on project_course to also be deleted. This is the code I have currently.

$deleteSQL = sprintf("DELETE FROM projects p
INNER JOIN project_course pc
WHERE p.Project_id=%s",
                   GetSQLValueString($_GET['Project_id'], "int"));

Anybody know how to do this? I haven't done a join to delete before, just a normal join.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

2

You dont have to explicitly do this with joined queries.You can use DELETE CASCADE in table definition. Refer How do I use on delete cascade in mysql?

Community
  • 1
  • 1
Ahamed Mustafa M
  • 3,069
  • 1
  • 24
  • 34