Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. SQL emptying a column

SQL emptying a column

Scheduled Pinned Locked Moved IT & Infrastructure
databasequestionannouncementlearning
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dlongwood
    wrote on last edited by
    #1

    Hi there. Ok, If I have a database with columns "FirstName" and "LastName" I could insert a row with no value for last name by calling INSERT INTO TableName (FirstName) VALUES ('Matt') Ok, easy. However, if I have a row already entered with a first and last name, how would I clear the first name to an empty value? By which I mean no value at all rather than an empty string. Can I do this with an UPDATE call? Is there a keyword to use such as "FirstName = NULL"? I could of course delete the row and add it again, but it seems like it should be easier than that.

    C 1 Reply Last reply
    0
    • D dlongwood

      Hi there. Ok, If I have a database with columns "FirstName" and "LastName" I could insert a row with no value for last name by calling INSERT INTO TableName (FirstName) VALUES ('Matt') Ok, easy. However, if I have a row already entered with a first and last name, how would I clear the first name to an empty value? By which I mean no value at all rather than an empty string. Can I do this with an UPDATE call? Is there a keyword to use such as "FirstName = NULL"? I could of course delete the row and add it again, but it seems like it should be easier than that.

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      I may not have the syntax exactly correct but try this out

      update TableName
      set LastName to NULL
      where FirstName = 'Matt';

      Chris Meech "what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002. "Microsoft hasn't ever enforced its patents. Apparently they keep them for defensive reasons only. Or, they could be waiting 'til they have a critical mass of patents, enforce them all at once and win the game of Risk that they're playing with the world." Chris Sells Feb 18, 2003.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups