一列,以这种格式显示card_number列的最后四位数字: XXXX-XXXX-XXXX-1234。换句话说,请使用X表示卡的前12位数字 数字和数字的最后四位数的实际数字。
SELECT Card_number, length(card_number) as cardLength, 'XXXX-XXXX-XXXX-'
+ right(card_number,4) as lastfourdigits
FROM orders;
答案 0 :(得分:0)
在MySQL中,可以使用concat()
函数而不是+
运算符来连接字符串。
SELECT card_number,
length(card_number) as cardlength,
concat('XXXX-XXXX-XXXX-', right(card_number, 4)) as lastfourdigits
FROM orders;