[MySQL]Insert語法比較

有關資料庫的討論, 都可以在這發表哦~~
回覆文章
頭像
tim
文章: 1380
註冊時間: 2008年 11月 26日, 00:49

[MySQL]Insert語法比較

文章 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.
多多留言, 整理文章, 把經驗累積下來.....
回覆文章