473,407 Members | 2,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

NOT NULL problems

pradeepjain
563 512MB
i ma creating a table like
Expand|Select|Wrap|Line Numbers
  1. create table mobile_master(id int AUTO_INCREMENT NOT NULL PRIMARY KEY,property1_name varchar(100) NOT NULL,property2_name varchar(100) NOT NULL,property3_name varchar(100) NOT NULL,property4_name varchar(100) NOT NULL,property5_name varchar(100) NULL,property6_name varchar(100) NULL,property7_name varchar(100) NULL,property8_name varchar(100) NULL,property9_name varchar(100) NULL,property10_name varchar(100) NULL,property11_name varchar(100) NULL,property12_name varchar(100) NULL,property13_name varchar(100) NULL,property14_name varchar(100) NULL,property15_name varchar(100) NULL)engine=INNODB;

but when i insert values with property2_name with no value something like this
Expand|Select|Wrap|Line Numbers
  1. insert into mobile_master  (property1_name,property2_name) values ('Brand','Model Number');

query gets accepted ...the NOT NULL factor is not coming into play...
Oct 15 '09 #1
3 2185
code green
1,726 Expert 1GB
You are not inserting NULL, you are inserting an empty value.
MySql will insert the default value for a field that is NOT NULL,
0 for INT, empty for string
Oct 15 '09 #2
pradeepjain
563 512MB
is there a way so that i make sure that there is a value in a column ?
Oct 15 '09 #3
code green
1,726 Expert 1GB
Do you mean reject the query if there are missing values?
This is better handled on the front end.

But you could try something weird like, setting the dafault value to NULL yet have the field set to NOT NULL. No idea what would happen then.

Or write a sql function to process the incoming data that so missing data is set to NULL

Can NULLIF() be used with INSERT INTO?
Oct 15 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ken | last post by:
Hi. This is a followup to my NULL macro vs. 0 question. It's in a separate thread, because I need to post using google, so my original thread isn't available to me yet :(. Anyway, I just...
29
by: Jason Curl | last post by:
I've been reading this newsgroup for some time and now I am thoroughly confused over what NULL means. I've read a NULL pointer is zero (or zero typecast as a void pointer), others say it's...
19
by: moxm | last post by:
I have a statement declares a globle variable like this : char *pname = NULL; Then I used splint to check the code, I got errors: err.c:8:15: Global pname initialized to null value: pname =...
5
by: David Sworder | last post by:
Hi, I've created a UserControl-derived class called MyUserControl that is able to persist and subsequently reload its state. It exposes two methods as follows: public void Serialize(Stream...
7
by: Dan | last post by:
I'm fairly new to C# and I am having some problems understanding int variables and null values. I have created a class that populates the values of it's fields from a DataReader in it's...
69
by: fieldfallow | last post by:
Hello all, Before stating my question, I should mention that I'm fairly new to C. Now, I attempted a small demo that prints out the values of C's numeric types, both uninitialised and after...
76
by: valentin tihomirov | last post by:
As explained in "Using pointers vs. references" http://groups.google.ee/group/borland.public.delphi.objectpascal/browse_thread/thread/683c30f161fc1e9c/ab294c7b02e8faca#ab294c7b02e8faca , the...
3
gingawarrior
by: gingawarrior | last post by:
Hi All, I've written some code to act as a validator for a set of form fields - it accepts a string of '~' delimited item names and then loops through to evaluate if they are either empty or =='999'...
14
by: Richard Heathfield | last post by:
In an otherwise excellent article, Eric Sosman said: <snip> ....or will read it without ever writing it, in which case the initialisation value protects you against reading an indeterminate...
5
by: Gilles Ganault | last post by:
Hello To handle an occasionnal flaky ADSL connection, I updated the database that handles incoming calls to have a column that is set to NULL, and then updated to either Y or N depending on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.