SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: INSERT question

  1. #1
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    INSERT question

    Hi,

    I have a table:

    CREATE TABLE `tbldoc` (

    `dcid` smallint(6) UNSIGNED NOT NULL auto_increment,
    `name` varchar(255) NOT NULL,
    `descr` varchar(255) NOT NULL,
    `type` enum('fo','fi','lk') NOT NULL default 'fo',
    `loc` varchar(255) NOT NULL default 'loc',
    `root` smallint(6) UNSIGNED NOT NULL default '0',
    `owner` varchar(25) NOT NULL default 'root',
    `faculty` smallint(6) UNSIGNED NOT NULL default '0',
    `vis` enum('1','2','3','4') NOT NULL default '1',
    `date` date NOT NULL,
    `dclock` bool NOT NULL default '0', PRIMARY KEY (`dcid`) ) TYPE=MyISAM;

    and I want to insert a record:


    INSERT INTO tbldoc SET
    dcid=0,

    name='Root folder',
    descr=' Placeholder, prevents any other records using dcid = 0',
    type='fo',
    loc='',
    root='0',
    owner='root',
    faculty='4',
    vis=5,
    date='01-01-2003',
    dclock=0;


    The problem comes when I look at the record it has inserted, the value for vis is '', any odeas apprecated! have tried vis='5' to no avail.
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,267
    Mentioned
    116 Post(s)
    Tagged
    1 Thread(s)
    first problem is 5 is not a valid value based on how the table is defined(1,2,3 and 4 are). The second is the insert syntax is incorrect. Insert syntax in SQL is

    INSERT INTO TableName (field1, field2, ..., fieldx) values (value1, value2, ..., valuex)
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    defined(1,2,3 and 4 are).
    whoops, lol. Thanks
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    dave, that syntax is valid in mysql
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hence I only quoted the - defined(1,2,3 and 4 are). - was in a rush so wasn't about to start a converstaion.
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  6. #6
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,267
    Mentioned
    116 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by r937
    dave, that syntax is valid in mysql
    Oops, sorry. Used to the standards compliant SQL format.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •