S
S
skipper_10082016-01-17 16:07:40
MySQL
skipper_1008, 2016-01-17 16:07:40

How to select phone numbers (`Phone`) in which the sum of the first three digits is equal to the sum of the last three?

How to select phone numbers (`Phone`) in which the sum of the first three digits is equal to the sum of the last three? The number consists of 6 digits.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
winbackgo, 2016-01-17
@winbackgo

for example

SET @phone = '894585454786';
SELECT @phone, (SUBSTR(@phone, 1, 1) + SUBSTR(@phone, 2, 1) + SUBSTR(@phone, 3, 1)) - (SUBSTR(@phone, -3, 1) + SUBSTR(@phone, -2, 1) + SUBSTR(@phone, -1, 1))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question