programmingislove
programmingislove

Reputation: 19

MySQL Select a range of letters

How to remove the letters between the first two letters and the last two letters? Is it something like a combination of LIKE and =<> ?

Table Name: Items_ordered

OrderDate      Item
------------------------
2015-07-01     Skateboard
2015-07-01     Life Vest
2015 -07-06    Parachute
2015-07-27     Umbrella   

Sample Output:

OrderDate      Item
--------------------
2015-07-01     Skrd
2015-07-01     List
2015-07-06    Pate
2015-07-27     Umla   

Upvotes: 0

Views: 131

Answers (1)

JohnHC
JohnHC

Reputation: 11205

Use left() and right()

select OrderDate, concat(left(Item,2), right(Item,2) )as NewItem
from Items_ordered

However, what happens with an item like 'Bag', with less than 4 letters?

Upvotes: 1

Related Questions