Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple insert query

Status
Not open for further replies.

johno77

Technical User
Nov 1, 2003
40
0
0
GB
Hello

my work doesnt normally bring me into contact with databases so consequently i do not know an awful lot. What i am trying to do is insert values into a table but some of my fields will be entered at a later date - how do i code this i.e. will the following work

insert into programming values('whatever,'yadayada','null');

or should i code using this statement

insert into programming values('whatever,'yadayada','');

thanks
 
Code:
insert into programming (fieldname1,fieldname2,fieldname3) values('whatever,'yadayada','');

[code]

you forgot the fieldnames ;)

and it's a personal choice of what you want but I believe that with null you don't need the single quotes.
 
hos2, it is not personal choice

if null has quotes around it, it is not null, it is a character string that says null

NULL is a keyword, and cannot have quotes around it


rudy
 
it was more the choice between NULL or an empty string '' that I meant
 
that's not a personal choice either

NULL is null

'' is an empty string and is not null

they are not the same thing at all

;-)
 
yep and that's also what I meant that it's a personal choiche if you want to have NULL or an empty string in the field. thought that I made that clear the second time.
 
Whichever you use, empty string ('') or NULL, be consistent as it could cause grief for people down the line.
I've seen people getting incorrect results when doing something like a SELECT * FROM table1 WHERE field2 IS NULL because some people used '' for null values;

Common practice however, is to use null.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top