简体   繁体   English

基于条件的SQL INSERT

[英]SQL INSERT based on criteria

I have a Song database that I have created using the Spotify Web API. 我有一个使用Spotify Web API创建的Song数据库。 At the moment my database has a table with the following columns; 目前,我的数据库有一个包含以下各列的表; spotify_uri, key, tempo. spotify_uri,键,速度。 The key column stores the songs key as an integer value Eg 0 = C, 1 = C♯/D♭, 2 = D, and so on. 键列将歌曲键存储为整数值,例如0 = C,1 =C♯/ D♭,2 = D,依此类推。

If I create a new column called a_key, what would be the statement to insert the value "C" in to the a_key column where key=0 ? 如果我创建一个名为a_key的新列,那么将在其中key = 0的a_key列中插入值“ C”的语句是什么?

Update table 
set a_key = 'C' 
where key = 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM