I have a dataset as follows:
SELECT * FROM all_trans LIMIT 6
+---------------+-------------+-----------+------------------+-----------------+-----------+----------+
| transaction_id|card_event_id|card_pos_id|card_point_country|transaction_label|module_name| post_date|
+---------------+-------------+-----------+------------------+-----------------+-----------+----------+
|0P2117055584563| 2480330365| E3KB2938| CZ| FUN0402007| regex|2022-01-17|
|0P2117055584563| 2480330365| E3KB2938| CZ| FUN04| mcc|2022-01-17|
|0P2117057388514| 2480338194| E3KB2938| CZ| FUN0402007| regex|2022-01-17|
|0P2117057388514| 2480338194| E3KB2938| CZ| FUN04| mcc|2022-01-17|
|0P2117058209585| 2480339519| E3KB2938| CZ| FUN0402007| regex|2022-01-17|
|0P2117058209585| 2480339519| E3KB2938| CZ| FUN04| mcc|2022-01-17|
I want to get the transactions with no 'regex' value in module_name (either with 'mcc' value or none whatsoever).
I tried:
SELECT a.transaction_id
FROM all_trans a
JOIN all_trans b ON a.transaction_id = b.transaction_id
WHERE a.module_name='mcc' AND b.module_name<>'regex'
LIMIT 100
But still getting transactions with both mcc and regex values in the column module_name.