sql - Is there a way to speed up this MySQL delete query? -


i’m using mysql 5.5.37. i’m trying figure out faster way write below query. have 2 tables, access_code , classroom. “classroom” table has foreign key constraint (access_code_id) primary key of access_code table. i’m trying delete records in access_code table have no link classroom table , have particular type id. i’m running …

delete access_code id in (select q.* (select a.id access_code left join lyc_classroom c on a.id = c.access_code_id a.access_code_type = 2 , c.access_code_id null) q); 

which taking long time. there faster way execute above query?

you don't need subqueries. use delete ... join syntax

delete  access_code left join lyc_classroom c on a.id = c.access_code_id a.access_code_type = 2 , c.access_code_id null 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -