Forum Moderators: open
(SELECT tableOne . * , tableTwo . * FROM TABLEONE AS tableOne
LEFT JOIN TABLETWO AS tableTwo USING ( col1 )
LEFT JOIN TABLETHREE AS tableThree USING ( col1 )
WHERE tableOne.col1 != '25202'
AND tableOne.col2 = 'ZZ'
AND tableThree.col3 = 'Y'
AND tableThree.col4 > ( UNIX_TIMESTAMP( ) -7200 )
AND tableOne.col5 LIKE 'F'
AND (tableOne.col6 LIKE 'M' OR tableOne.col6 LIKE 'M-B')
AND tableOne.col1 NOT IN (20758)
GROUP BY tableOne.col1
ORDER BY tableOne.col7 DESC LIMIT 50)
UNION
( SELECT tableOne . * , tableTwo . * FROM TABLEONE AS tableOne
LEFT JOIN TABLETWO AS tableTwo USING ( col1 )
LEFT JOIN TABLETHREE AS tableThree USING ( col1 )
WHERE tableOne.col1 != '25202'
AND tableThree.col3 = 'Y'
AND tableThree.col4 > ( UNIX_TIMESTAMP( ) -7200 )
AND tableOne.col5 LIKE 'F'
AND (tableOne.col6 LIKE 'M' OR tableOne.col6 LIKE 'M-B')
AND tableOne.col1 NOT IN (20758)
GROUP BY tableOne.col1
ORDER BY tableOne.col7 DESC LIMIT 50)
LIMIT 0, 5 ;
EXPLAIN:
Rows: 7
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY tableThree range col4,col3,col1 col4 5 NULL 549 Using where; Using temporary; Using filesort
1 PRIMARY tableOne eq_ref PRIMARY,col2,col5,col6 PRIMARY 4 Database.tableThree.col1 1 Using where
1 PRIMARY tableTwo eq_ref PRIMARY PRIMARY 4 Database.tableOne.col1 1
2 UNION tableThree range col4,col3,col1 col4 5 NULL 549 Using where; Using temporary; Using filesort
2 UNION tableOne eq_ref PRIMARY,col5,col6 PRIMARY 4 Database.tableThree.col1 1 Using where
2 UNION tableTwo eq_ref PRIMARY PRIMARY 4 Database.tableOne.col1 1
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL runs in about 0.03
what would that possibly reveal?