I am using MySQL to perform this operation. For example I want to select phone numbers that do not begin with '456'. What is the query to get tuples where the number does not begin with 456 and does not appear any where else.
I tried WHERE phone NOT LIKE 'E6%'
but that deselects all numbers with 456 in them.
List of phone numbers
Result I got. This removes all numbers with 456 in them. Not just ones at the beginning
CodePudding user response:
None of your phone numbers begin with 456
, they all begin with 1-
. It seems like you want to check if the second part of the number is 456
, not the beginning. So use
WHERE number NOT LIKE '%-456-%'
CodePudding user response:
If i understand your requirement correctly this should work:
WHERE phone NOT LIKE '%-456%'
This should ignore all phone numbers with 456 after prefix 1- and with the numbers in front of the third block