-
-
Save brandon-beacher/183970 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's my sample data set | |
mysql> SELECT tf.id, tf.authorization_id_response, tf.tran_type FROM transaction_feeds tf; | |
+-----+---------------------------+-----------+ | |
| id | authorization_id_response | tran_type | | |
+-----+---------------------------+-----------+ | |
| 239 | 223672 | 9120 | | |
| 240 | 223672 | 9220 | | |
| 241 | 223673 | 9120 | | |
+-----+---------------------------+-----------+ | |
3 rows in set (0.00 sec) | |
I'd like to be write a query that will find all items in the table with | |
tran type 9120 which do not also have another entry in the table with the | |
same authorization_id_response. | |
SELECT id, authorization_id_response, tran_type | |
FROM transaction_feeds tf | |
WHERE NOT EXISTS ( | |
SELECT authorization_id_response | |
FROM transaction_feeds | |
WHERE id != tf.id | |
AND authorization_id_response = tf.authorization_id_response | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment