Search code examples
javamysqlsqlsql-delete

Delete query in mysql


I want to delete rows from multiple tables. I know the select query, but I need an exact delete query for all the columns that are defined below:

SELECT j.application_id, 
       j.first_name, 
       j.last_name, 
       c.description, 
       l.description, 
       p.description, " +
      "j.email, 
       j.date_applied, 
       j.application_status, 
       j.dob, j.current_city, j.phone_mobile, j.phone_residence " +
 "FROM jobapp.job_applications j,
       jobapp.countries c, 
       jobapp.countries l , 
       jobapp.job_locations p " +
"WHERE j.preferred_location = p.id 
   AND j.current_country = l.id 
   AND j.nationality = c.id "; //+
  //"and application_status like ? and first_name like ? and last_name like ? and email like ?";

The query works fine using MySQL, but I need an delete query for the exact columns where the rows are get deleted...


Solution

  • delete statements are structured like:

    DELETE FROM table WHERE condition.
    

    you should replace condition with the primary key from you query above (if it is present) and reference each table one at a time.