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

No comments:

Post a Comment