0

I have a table with an id column, an email column, and a password column. The id column is set to primary key and auto increment as shown here:

screenshot

Using MySQL workbench, I'm sending

INSERT INTO users VALUES ('a', 'b')

but it says that the "column count doesnt match the value count at row 1" which to me means that it's expecting 3 values and not 2. But according to this post, I should be able to just use two values as the id column will auto increment itself.

Clearly I am wrong about something because this is not working. What am I doing wrong?

Community
  • 1
  • 1
jros
  • 714
  • 1
  • 10
  • 33

1 Answers1

3

Always include the column list when using insert (unless you really know what you are doing):

INSERT INTO users(email, password)
    VALUES ('a', 'b');

The id column will be auto incremented, if it is set to auto increment.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • That fixed it. I've actually never seen that done before. thanks, I'l accept when i can – jros Jul 09 '15 at 02:49