0

Im trying to change the display of numbers of a certain column in my database. The table is called member_records and the specific field is called userID (int type) and the data under userID varies in length(in terms of number of characters) but Im only interested in the last 7 digits. Anyone with any idea how I can make the field userID display only the last 7 digits?

7
  • varies in length(in terms of number of characters)... What is the type of the column? Int or Varchar? - BTW: this question has nothing to do with phpmyadmin Commented May 2, 2019 at 9:56
  • @B001its an int type of column Commented May 2, 2019 at 9:58
  • Im only interested in the last 7 digits... So why don't you just store the last 7 digits Commented May 2, 2019 at 10:00
  • @B001 Because Im not the one doing the input. Thats user input Commented May 2, 2019 at 10:02
  • what have you done so far to achieve your output? Commented May 2, 2019 at 10:03

1 Answer 1

1

You can just take the modulus with 10,000,000 to extract the last 7 digits of an integer. For example,

create table member_records (user_id int);
insert into member_records values
(12359725),
(445),
(923587356),
(389475679);

SELECT user_id % 10000000 AS user_id
FROM member_records

Output:

user_id
2359725
445
3587356
9475679

Demo on dbfiddle

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! This has been very helpful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.