homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Gold Sponsor 2015!
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

INSERT vs. UPDATE for column data
Can I use UPDATE if the column value is NULL?

5+ Year Member

Msg#: 3674253 posted 5:48 pm on Jun 13, 2008 (gmt 0)


I'm wondering if it's possible to use UPDATE on a row where it's unknown whether the column being updated already has a value or not.

If the column's value is set to NULL, will UPDATE work? Or do I really need to test for NULL and write either an UPDATE or an INSERT query? I'd really like to streamline my code by not having to do the test, but I don't know how far UPDATE will go.

By the way, I looked at REPLACE INTO, but I'm not worried about an entire row of data, just a single column in an existing row.




WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Msg#: 3674253 posted 8:26 am on Jun 14, 2008 (gmt 0)

INSERT inserts a new ROW.
UPDATE modifies an existing row's VALUE(s).


5+ Year Member

Msg#: 3674253 posted 7:55 pm on Jun 14, 2008 (gmt 0)

Thanks. Of course you're right. That clears things up for me. UPDATE it is!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved