Showing posts with label MySQL copy value of field in one column to another field in the same column of table. Show all posts
Showing posts with label MySQL copy value of field in one column to another field in the same column of table. Show all posts

Tuesday, 13 May 2014

Update One column value in another column in Mysql




Hi,


For updating Value from one column to another use this


update Table_name set Column_name1 = Column_name2


But if  you want to copy specified character from a column then 



update Table_name set Column_name1 =
(
   SELECT LEFT(
Column_name2,INSTR(Column_name2,",")-1) 

)



SELECT LEFT(Column_name2,INSTR(Column_name2,",")-1) 

This query will select only characters before ,(Comma).


You can modify it as per your requirement.You can use slash or any other character...

Thanks
Shakun