1 頁 (共 1 頁)

[MySQL]Insert語法比較

發表於 : 2011年 5月 25日, 10:36
tim
在 MySQL 中, 於 insert 時, 可以使用一般的

insert into table (a, b, c) values (value_a, value_b, value_c)

也可以使用

insert into table set a=value_a, b=value_b, c=value_c

這兩者間是否有差異?

基本上是一樣的, 可以參考這篇文章:

http://stackoverflow.com/questions/8617 ... -table-set

或是官方的這篇:

http://dev.mysql.com/doc/refman/4.1/en/insert.html
INSERT inserts new rows into an existing table. The INSERT ... VALUES and INSERT ... SET forms of the statement insert rows based on explicitly specified values. The INSERT ... SELECT form inserts rows selected from another table or tables. The INSERT ... VALUES form with multiple value lists is supported in MySQL 3.22.5 or later. The INSERT ... SET syntax is supported in MySQL 3.22.10 or later.