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?
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