Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7854311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:01:20+00:00 2026-06-02T20:01:20+00:00

Hi there I have a question about Null values. Basically I have a bunch

  • 0

Hi there I have a question about Null values.

Basically I have a bunch of variables and I would like to do a bunch of checks then add values at the end however some of these values will need to be NULL.

so for example if a value is not set I would like to set the value of the variable to null so that it will not put anything in when I insert to the database.

$sql = "INSERT into specified table the values (?, ?,?)":
$params = "$param1, $NULLVALUEparam2, $param3);

so basically the same query will be executed each time but some input from the form are allowed to be left empty, how do I add these as NULL?

back story I am creating a registration page and some information is not required. the values are being sent via method POST to this action page where they are added to the database.

Am I going about this wrong, is there a better way? Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:01:23+00:00Added an answer on June 2, 2026 at 8:01 pm

    If you want to insert NULL into a specific column in a row you use the keyword NULL

    INSERT INTO yourtable (id, created_at, string, string1)
    VALUES (NEWID(), GETDATE(), 'your string you have', NULL)
    

    This inserts a row and place it as NULL.

    If you don’t have a value for a specific column you don’t even need to insert it, then you just skip it.

    INSERT INTO yourtable (id, created_at, string)
    VALUES (NEWID(), GETDATE(), 'your string you have')
    

    This will add a row and leave the string1 column NULL. But then, of course, your column must allow NULL values in both circumstances.

    So your code should skip the column OR just write NULL as string when you build your sql statement that you execute after.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about why there is such a difference in speed between
I would like app to add several (2k) words to UserDictionary. I have experimented
There have been several questions posted to SO about floating-point representation. For example, the
There have been several questions over the past few days about the proper use
I have a fairly simple question about these 2 templating engines. I'm trying to
As a huge fan of C++, there have been a question in my mind.
i have a question. There is application class in my program. It is inherited
I have a question regarding using Semaphores HANDLE WINAPI CreateSemaphore(...); Is there anyway I
I have this question, i am just throwing it out there. I am implementing
I have a simple question. I have this bitmap Is there a way with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.