Mysql Merge 2 Columns in table but prefer first column value over second -


i have 2 column in database like:

 omi   |  iut    |    final ------------------------------------------------  98234 |         |           |  v3455  |     09876 |  v5537  |    

i have column "final" empty , want merge these 2 column in third column like"

 omi   |  iut    |    final ------------------------------------------------  98234 |         |   98234        |  v3455  |   v3455  09876 |  v5537  |   09876 

so

if omi empty .. take iut value
if iut empty .. take omi value
if both have values, take omi value

any help?

update tablename set final=if(omi='',iut,omi);


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -