SQL SELECT Replace country names with abbreviations -


my query looks this:

select o.customerid, null emptycolumn, o.shipfirstname, o.shipcountry, c.emailaddress  orders o, customers c  o.customerid = c.customerid 

and results like,

1,,john,united states,john@example.com 2,,peter,canada,peter@example.com 

but need change "united states" "us" , "canada" "ca". how can this?

you can use case,

select  o.customerid, null emptycolumn, o.shipfirstname,          case when o.shipcountry = 'united states' 'us'         when o.shipcountry = 'canada' 'ca'         end,         c.emailaddress orders o, customers c o.customerid = c.customerid 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -