mysql (5.1) insert syntax > col_name=value?
Is there a way in mysql to insert a new row in a way that more directly associates a value with its column (rather than table(col_name) values(value)
)? When inserting a lot of values at one time, listing them in-line gets rather confusing and leads to errors/mistakes.
I'm looking for something more like UPDATE
's syntax of SET col_name='value'
.
I see in the mysql doc for INSERT there is the following:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
SET col_name={expr | DEFAULT}, ...
[ ON DUPLICATE KEY UPDATE
col_name=expr
[, col_name=e开发者_如何学Goxpr] ... ]
but that is just for duplicates :/
In the MySQL docs, [text]
means "text
is optional". So this is perfectly valid:
INSERT INTO table
SET col1='value1', col2='value2'...
精彩评论