troubleshooting Question

Using PhP/MySQL, how can I delete records from two tables with a common user_id

Avatar of Chadd C
Chadd C asked on
2 Comments1 Solution1078 ViewsLast Modified:
I'm trying to delete all records (by user_id) from two tables. Below is my script. It's not generating errors but its also not deleting records.  Hopefully someone can lend some clarity!

// Get the user ID of the user to delete
$user_id = $_GET['user_id'];

// Build the DELETE statement
$delete_query = sprintf("DELETE FROM users t1 INNER JOIN user_training_items t2 ON t1.user_id=t2.user_id WHERE t1.user_id= %d",

// Delete the user from the database
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros