The post shows how to format 10-digit telephone numbers in MySQL as US-style numbers with hyphens using CONCAT, LEFT, MID, and RIGHT. It filters orders from US, Canada, and Puerto Rico and returns the original and formatted phone values.

if you have a telephone field in a table where numbers have been entered in the format 1234567890 then use this to format it as 123-456-7890

select
  o.orderid,
  o.status,
  o.b_country,
  o.phone,
  CONCAT(LEFT(o.phone, 3), '-', MID(o.phone, 4, 3), '-', RIGHT(o.phone, 4)) AS 'formatted_phone'
from
	orders as o
where
	o.b_country IN ('US','CA','PR')
  and length(o.phone) = 10
order by o.orderid desc
limit 100