使用select in update子句将mysql varchar字段强制为upper

时间:2012-09-06 12:58:53

标签: mysql

尝试更新表格,以便字段将其内容更改为大写。

UPDATE `schools` SET `postcode` = 
UPPER(
(SELECT `postcode` FROM `schools` WHERE 1)
)

试过这个

UPDATE `schools` SET `postcode` = 
UPPER( 
SELECT `postcode` FROM  (SELECT * FROM `schools`) AS x WHERE `postcode`!=''
) WHERE 1

我知道这是可能的,但不能用语法

2 个答案:

答案 0 :(得分:1)

试试这个:

UPDATE `schools` 
SET `postcode` =UPPER(`postcode`)

答案 1 :(得分:0)


你应该这样试试

UPDATE schools SET postcode =UPPER(SELECT `postcode` FROM `schools` WHERE ur_column = values)