CREATE TABLE t1 ( f1 int NOT NULL , f2 int, f3 int, KEY (f3,f2), PRIMARY KEY (f1)) ;
INSERT IGNORE INTO t1 VALUES (19,1,NULL),(20,5,'r');
SELECT * FROM t1 WHERE (t1.f1 > 238 OR t1.f2 NOT BETWEEN 238 AND 238 ) AND t1.f3 != 'y' AND t1.f2 BETWEEN 238 AND 238 AND ( t1.f3 = 'u' OR t1.f1 = 245 );
Even simpler, join is not necessary:
CREATE TABLE t1 ( f1 int NOT NULL , f2 int, f3 int, KEY (f3,f2), PRIMARY KEY (f1)) ; ,(20,5, 'r');
INSERT IGNORE INTO t1 VALUES (19,1,NULL)
SELECT * FROM t1 WHERE (t1.f1 > 238 OR t1.f2 NOT BETWEEN 238 AND 238 ) AND t1.f3 != 'y' AND t1.f2 BETWEEN 238 AND 238 AND ( t1.f3 = 'u' OR t1.f1 = 245 );