How to prevent 3 nested MySQL queries from timing out -


i want delete records in t3 field names in t2 missing, if meet record id t1.

the query t1:

select max(id) t1 name1 = "xxx" , user_id = '$id' 

works fine.

the t2 query:

select name2 t2 record in (select max(id) t1 name1 = "xxx" , user_id = '$id') 

also works fine, takes while.

but t3 query:

delete t3 name3 not in (select name2 t2 record in (select max(id) t1 name1 = "xxx" , user_id = '$id')); 

results in "#2006 - mysql server has gone away"

how query result within reasonable time?

i think can use join queries instead?

select name2, max(t1.id)  t2 inner join t1 on t2.t1_id = t1.id name1="xxx" , user_id='$id' 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -