compare - MySQL doesn't exclude query results from other query -
i have experiment db, , try participants wish recontacted except ones participated in 1 specific experiment. query works, except doesn't include participants took part in experiment, include participants took part in experiment , other experiments. excuse sloppy code!
select distinct t1.`par_name`, t1.`email`, t1.`comment` `par` t1, `exp` t2, `pie` t3 t1.`par_id` = t3.`par_id` , t3.`exp_id` = t2.`exp_id` , t1.`recontact`!= 'n' , t1.`email`!= " " , t1.`mothertounge` = 'deu' or t1.`mothertounge` = '' , t1.`age` between 18 , 35 , t1.`par_name` not in(select t1.`par_name` `par` t1, `exp` t2, `pie` t3 t1.`par_id` = t3.`par_id` , t3.`exp_id` = t2.`exp_id` , t3.`exp_id` = '15et001') group `par_name`;
im not 100% think need enclose joins
select distinct t1.`par_name`, t1.`email`, t1.`comment` `par` t1, `exp` t2, `pie` t3 (t1.`par_id` = t3.`par_id`) , (t3.`exp_id` = t2.`exp_id`) , (t1.`recontact`!= 'n') , (t1.`email`!= " ") , // here change (t1.`mothertounge` = 'deu' or t1.`mothertounge` = '') , (t1.`age` between 18 , 35) , t1.`par_name` not in(select t1.`par_name` `par` t1, `exp` t2, `pie` t3 t1.`par_id` = t3.`par_id` , t3.`exp_id` = t2.`exp_id` , t3.`exp_id` = '15et001') group `par_name`;
since have or , need enclose ().
give try!
Comments
Post a Comment