Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use Join with Delete command?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 282
    Comment on it

    To delete records of more than one table we can use joins. Joins are used to combine two table. Here, we will use join to delete the records from more than one table.

    Syntax:

    DELETE T1, T2 FROM T1 INNER JOIN T2 ON T1.key = T2.key WHERE condition
    

    Here we used inner join to delete the records from two tables i.e., t1 and t2 depending on some where condition.

    For example: Suppose we have two table office and employees. Every employee have some office code. We have to remove all the details related two the offices and employees whose office code is 5. For this we will execute the following MySQL statement:

    DELETE offices, employees  FROM offices INNER JOIN employees  ON employees.officeCode = employees.officeCode WHERE offices.officeCode = 5
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: