Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with the last part(last column) of this question for MySQL. 3. Write a

ID: 3736706 • Letter: N

Question

Need help with the last part(last column) of this question for MySQL.

3. Write a SELECT statement that returns these columns from the Orders table:
The card_number column
The length of the card_number column
The last four digits of the card_number column
When you get that working right, add the columns that follow to the result set. This is more difficult because these columns require the use of functions within functions.
A column that displays the last four digits of the card_number column in this format: XXXX-XXXX-XXXX-1234. In other words, use Xs for the first 12 digits of the card number and actual numbers for the last four digits of the number.

Explanation / Answer

SELECT CardNumber , LEN ( CardNumber ) AS CardLen , RIGHT( CardNumber , 4 ) AS Last4Dig , CONCAT ( 'XXXX-XXXX-XXXX-' ,RIGHT( CardNumber , 4 )) AS SecuredNum FROM Orders ;