SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    create and insert throwing error.

    Hi,

    Getting back into this after a couple of weeks away.

    I am creating a table and then trying to insert values. MySQL throws the error 1136, and says that column count doesn't match value count at row 1.

    what am I missing please?

    Code:
    CREATE TABLE IF NOT EXISTS vat_rates
    ( vat_rate decimal(5,2) NOT NULL
    , date_from date NOT NULL
    , date_to date default NULL
    , PRIMARY KEY  (vat_rate,date_from)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    INSERT INTO vat_rates (vat_rate) VALUES
    ('17.5', '2008-04-05', ''),
    ('15.00', '2008-12-01', '');
    bazz

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,248
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    this one's easy, bazz, you just gots to think a little harder

    "column count doesn't match value count"

    let's see...
    Code:
    INSERT INTO vat_rates (vat_rate)
    okay, that's 1 column...



    Code:
     VALUES ('17.5', '2008-04-05', '')
    and that's 3 values

    see it now?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru
    Join Date
    Sep 2008
    Posts
    977
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yep I got it, just now, when I hit the same issue with another table. I'll have to build up my momentum again.

    Thanks Rudy.


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
  •