MySQL how to extract data from one column using Substring and put to another column under same ID within same table -


let's have table people like

id      |   name        |       extracted ----------------------------------------- 1       |   roger       | ----------------------------------------- 2       |   anthony     | ----------------------------------------- 3       |   maria       | ----------------------------------------- 

we use

select substring(name, 1, 3) people.name name '%thon%'  

it find "anthony" , extract 3 first chars - result : ant

how put result against same id table looks like

id      |   name        |       extracted ----------------------------------------- 1       |   roger       | ----------------------------------------- 2       |   anthony     |       ant ----------------------------------------- 3       |   maria       | ----------------------------------------- 

try

update people set extracted = left(`name`,3) `name` '%thon%' 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -