更新表的语法是:
UPDATE country
SET country_name = 'america'
WHERE condition;
例如:
我有一个包含3列的国家/地区表:continent
,country_id
和country_name
。
在continent
和country_id
中,所有值仍未完成,仍设置为null(该值设置为varchar(256)
)。
在country_name栏中,我有"澳大利亚","美国","日本","加拿大"。
我如何更新" usa"去美国"不使用WHERE条件?
答案 0 :(得分:1)
如果您不允许使用[{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]jsonString: [{"globalTradeID":116229026,"tradeID":"4728521","date":"2017-05-01 11:21:43","rate":"0.00004113","amount":"6118.34548991","total":"0.25164754","fee":"0.00150000","orderNumber":"40272934869","type":"buy","category":"exchange"},{"globalTradeID":116227160,"tradeID":"4728350","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"4.08198005","total":"0.00016797","fee":"0.00250000","orderNumber":"40271626179","type":"buy","category":"settlement"},{"globalTradeID":116227159,"tradeID":"4728349","date":"2017-05-01 11:17:51","rate":"0.00004115","amount":"998.42429344","total":"0.04108515","fee":"0.00250000","orderNumber":"40271625180","type":"buy","category":"marginTrade"},{"globalTradeID":116226661,"tradeID":"4728312","date":"2017-05-01 11:16:50","rate":"0.00004125","amount":"1000.00000000","total":"0.04125000","fee":"0.00150000","orderNumber":"40271087718","type":"sell","category":"marginTrade"},{"globalTradeID":116207504,"tradeID":"4726343","date":"2017-05-01 10:44:17","rate":"0.00004169","amount":"6046.78987712","total":"0.25209066","fee":"0.00150000","orderNumber":"40258966851","type":"sell","category":"exchange"},{"globalTradeID":116165595,"tradeID":"4721962","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"5908.02441914","total":"0.24122463","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165589,"tradeID":"4721961","date":"2017-05-01 09:19:29","rate":"0.00004083","amount":"3.77406151","total":"0.00015409","fee":"0.00150000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":116165569,"tradeID":"4721960","date":"2017-05-01 09:19:28","rate":"0.00004083","amount":"144.21964328","total":"0.00588848","fee":"0.00250000","orderNumber":"40228860987","type":"buy","category":"exchange"},{"globalTradeID":115826811,"tradeID":"4679609","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"153.45158215","total":"0.00584650","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826810,"tradeID":"4679608","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"262.48126299","total":"0.01000053","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826809,"tradeID":"4679607","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"5253.48043078","total":"0.20015760","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"},{"globalTradeID":115826808,"tradeID":"4679606","date":"2017-04-30 23:10:36","rate":"0.00003810","amount":"836.80554752","total":"0.03188229","fee":"0.00250000","orderNumber":"40019069988","type":"sell","category":"exchange"}]
进行某种理论练习,可以使用where
:
case
这将更新每一行,但它只会更改'usa'的值。
答案 1 :(得分:1)
我从你的评论中了解到你可以在哪里使用但你不能使用country_id字段,所以这可能就是你所需要的。
UPDATE country
SET country_name = 'america'
WHERE country_name = 'usa';