编辑mysql表 [英] Edit mysql table

查看:53
本文介绍了编辑mysql表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编辑整个 mysql 表的行.

I want to edit an entire mysql table's row.

我根本不懂 mysql,所以在基本编程中这就是我想做的:

I don't really know mysql at all, so in basic programming this is what I want to do:

来自表格视频中的行年份:

from row year in table videos:

这里的关键是我想添加 19/20 而不是添加它.

The key here is that I want to prepend 19/20 and not add it.

if (year < 50)
    year = year+2000
else
    year = year+1900

我该怎么做?

推荐答案

试试这个:

UPDATE yourtable
SET year = year + IF(year >= 50, 1900, 2000)

如果您的列是整数类型和字符类型,这都适用.

This will work both if your column is an integer type and also if it is a character type.

这篇关于编辑mysql表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆