Ah ha!

Thank you Aleksandar. That's a much better solution. In fact, now youv'e told me this, I looked in the Manual, and the scales where lifted from my eyes. You've saved me re-writing (and re-thinking) a large chunk of PHP.

For anyone else's future reference it's all there in plain english - which confirms me as an idiot.

"6.4.3 INSERT Syntax

    INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name [(col_name,...)]
        VALUES ((expression | DEFAULT),...),(...),...
        [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name [(col_name,...)]
        SELECT ...
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
        [INTO] tbl_name
        SET col_name=(expression | DEFAULT), ...
        [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]"

and in the not so small print ;-)

""Any column not explicitly given a value is set to its default value. For example, if you specify a column list that doesn't name all the columns in the table, unnamed columns are set to their default values. Default value assignment is described in section 6.5.3 CREATE TABLE Syntax. You can also use the keywordDEFAULT to set a column to its default value. (New in MySQL 4.0.3.) This makes it easier to write INSERTstatements that assign values to all but a few columns, because it allows you to avoid writing an incompleteVALUES() list (a list that does not include a value for each column in the table). Otherwise, you would have to write out the list of column names corresponding to each value in the VALUES() list"

Which is of course what I was trying to get at! ;-)

Thanks again.

R


On 5 Jan 2004, at 17:37, Aleksandar Bradaric wrote:


insert into `property` values ('', 'Riverside View', default);


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to