mysql> SELECT action_id,transaction_date -> FROM transactions LEFT JOIN actions -> ON transactions.transaction_id = actions.transaction_id -> LEFT JOIN merchants ON merchant_id = idmerchants -> WHERE mdf_20 = '1442a29888840b0b9505d34da6cd8897d153976d' -> AND action_type IN ('capture','sale') -> AND processor_settlement_date IS NULL -> UNION -> SELECT action_id,transaction_date FROM profitorius.actions -> WHERE transaction_id LIKE '1442a29888840b0b9505d34da6cd8897d153976d%' -> AND ABS(amount) = ABS('49.95') AND success = 1 -> AND action_type IN ('capture','sale') -> AND processor_settlement_date IS NULL -> ORDER BY transaction_date; +-----------+---------------------+ | action_id | transaction_date | +-----------+---------------------+ | 1061578 | 2014-08-05 19:36:18 | +-----------+---------------------+ 1 row in set (0.00 sec) mysql> SELECT action_id,transaction_date -> FROM transactions LEFT JOIN actions -> ON transactions.transaction_id = actions.transaction_id -> LEFT JOIN merchants ON merchant_id = idmerchants -> WHERE mdf_20 = 'a4bbf326102e3064a8d9e06558c4b5e2020ee353 ' -> AND action_type IN ('capture','sale') -> AND processor_settlement_date IS NULL -> UNION -> SELECT action_id,transaction_date FROM profitorius.actions -> WHERE transaction_id LIKE 'a4bbf326102e3064a8d9e06558c4b5e2020ee353 %' -> AND ABS(amount) = ABS('4.95') AND success = 1 -> AND action_type IN ('capture','sale') -> AND processor_settlement_date IS NULL -> ORDER BY transaction_date; +-----------+---------------------+ | action_id | transaction_date | +-----------+---------------------+ | 1061498 | 2014-08-05 18:50:11 | +-----------+---------------------+ 1 row in set (0.00 sec)