SELECT UNIX_TIMESTAMP(), p.str2, p.str0, p.rng0, p.rng2, p.rng3, p.dec2, p.str4, p.str3, p.rng4, p.rng5 FROM ( SELECT DISTINCT mx.account_name, mx.str0, mx.str1, mx.str2, mx.str3, mx.str4, mx.str5, mx.str6, mx.str7, mx.str8, mx.str9, mx.rng0, mx.rng1, mx.rng2, mx.rng3, mx.rng4, mx.rng5, mx.rng6, mx.rng7, mx.rng8, mx.rng9, mx.dec0, mx.dec1, mx.dec2, mx.dec3, mx.dec4, mx.dec5, mx.dec6, mx.dec7, mx.dec8, mx.dec9, mx.chk0_opt0, mx.chk0_opt1, mx.chk0_opt2, mx.chk0_opt3, mx.chk0_opt4, mx.chk1_opt0, mx.chk1_opt1, mx.chk1_opt2, mx.chk1_opt3, mx.chk1_opt4, mx.chk2_opt0, mx.chk2_opt1, mx.chk2_opt2, mx.chk2_opt3, mx.chk2_opt4, mx.chk3_opt0, mx.chk3_opt1, mx.chk3_opt2, mx.chk3_opt3, mx.chk3_opt4, mx.chk4_opt0, mx.chk4_opt1, mx.chk4_opt2, mx.chk4_opt3, mx.chk4_opt4, mx.chk5_opt0, mx.chk5_opt1, mx.chk5_opt2, mx.chk5_opt3, mx.chk5_opt4, mx.chk6_opt0, mx.chk6_opt1, mx.chk6_opt2, mx.chk6_opt3, mx.chk6_opt4, mx.chk7_opt0, mx.chk7_opt1, mx.chk7_opt2, mx.chk7_opt3, mx.chk7_opt4, mx.chk8_opt0, mx.chk8_opt1, mx.chk8_opt2, mx.chk8_opt3, mx.chk8_opt4, mx.chk9_opt0, mx.chk9_opt1, mx.chk9_opt2, mx.chk9_opt3, mx.chk9_opt4, mb.item_name, mb.str0 as _str0, mb.str1 as _str1, mb.str2 as _str2, mb.str3 as _str3, mb.str4 as _str4, mb.str5 as _str5, mb.str6 as _str6, mb.str7 as _str7, mb.str8 as _str8, mb.str9 as _str9, mb.rng0 as _rng0, mb.rng1 as _rng1, mb.rng2 as _rng2, mb.rng3 as _rng3, mb.rng4 as _rng4, mb.dec0 as _dec0, mb.dec1 as _dec1, mb.dec2 as _dec2, mb.dec3 as _dec3, mb.dec4 as _dec4, mb.chk0_opt0 as _chk0_opt0, mb.chk0_opt1 as _chk0_opt1, mb.chk0_opt2 as _chk0_opt2, mb.chk0_opt3 as _chk0_opt3, mb.chk0_opt4 as _chk0_opt4, mb.chk1_opt0 as _chk1_opt0, mb.chk1_opt1 as _chk1_opt1, mb.chk1_opt2 as _chk1_opt2, mb.chk1_opt3 as _chk1_opt3, mb.chk1_opt4 as _chk1_opt4, mb.chk2_opt0 as _chk2_opt0, mb.chk2_opt1 as _chk2_opt1, mb.chk2_opt2 as _chk2_opt2, mb.chk2_opt3 as _chk2_opt3, mb.chk2_opt4 as _chk2_opt4, mb.chk3_opt0 as _chk3_opt0, mb.chk3_opt1 as _chk3_opt1, mb.chk3_opt2 as _chk3_opt2, mb.chk3_opt3 as _chk3_opt3, mb.chk3_opt4 as _chk3_opt4, mb.chk4_opt0 as _chk4_opt0, mb.chk4_opt1 as _chk4_opt1, mb.chk4_opt2 as _chk4_opt2, mb.chk4_opt3 as _chk4_opt3, mb.chk4_opt4 as _chk4_opt4 FROM crm_account as mx LEFT JOIN crm_account_item as mb ON mx.id = mb.account_id where true GROUP BY mx.buyer_id, mx.account_name having true and ( true or true or false ) and ( true or false ) and ( true or false ) and ( true or false ) ) p having true having true and ( true or true or false ) and ( true or false ) and ( true or false ) and ( true or false )