If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > INSERT stattement syntax (autoincrementing field)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-04, 02:05
divined divined is offline
Registered User
 
Join Date: Apr 2004
Posts: 110
INSERT stattement syntax (autoincrementing field)

Hello everybody

I`ve created a table with just three fields. The first is an auto incrementing integer field and the second is a string. Finally, there exists a third Boolean field. The SQL statement used to create the relation (table) is shown below :

CREATE TABLE TEXNIKOS(Kwd_Texnikou INTEGER UNSIGNED AUTO_INCREMENT,
Onomatepwnymo VARCHAR(30) NOT NULL,
Eswterikos BOOL,
PRIMARY KEY(Kwd_Texnikou)) TYPE=INNODB;

Since my first field is an auto integer, I was wondering what syntax I have to use in order to Insert a record in this table?

thx, in advance

George Papadopoulos
Reply With Quote
  #2 (permalink)  
Old 09-09-04, 02:53
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
you can either assign a NULL to it, assign a value to it, or leave it out of the statement altogether:
Code:
insert into TEXNIKOS
values ( null, 'foo', true )  
;
insert into TEXNIKOS
values ( 3, 'bar', 0 )  
;
insert into TEXNIKOS ( Onomatepwnymo , Eswterikos )
values (  'qux', 0 )  
;
insert into TEXNIKOS ( Onomatepwnymo  )
values (  'fap'  )  
;
select * from TEXNIKOS
;

Kwd_Texnikou  Onomatepwnymo Eswterikos
  1             foo             1
  3             bar             0
  4             qux             0
  5             fap             NULL
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-09-04, 03:25
divined divined is offline
Registered User
 
Join Date: Apr 2004
Posts: 110
very nice. thank you!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On