473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

auto_increment in mysql

i have created the following table:

create table test (field1 varchar(100), id integer unsigned not null
auto_increment, unique (field1), primary key (id));

When i try to insert some values by using the following statement

insert into test values ("this is a test");

I was told "column count does not match value count at row 1".

I could not figure out what's wrong with the syntax. Could someone help me
out. Thanks.
Jul 19 '05 #1
4 4654
BDR
You can't use that type of syntax when inserting into one field only.

Using a blatant insert into, your input value count MUST match the
number of columns in the table, like this:

insert into test values "this is a test", '0'

This type of insert is not recommended because if your database ever
changes, then all of your programmed query statements will have to
change too.

Better:
insert into test (field1), ("this is a test")

or
insert into test (field1), ("this is test1", "this is test2", "this is
test3")

or

insert into test set field1="this is a test"

jjliu wrote:
i have created the following table:

create table test (field1 varchar(100), id integer unsigned not null
auto_increment, unique (field1), primary key (id));

When i try to insert some values by using the following statement

insert into test values ("this is a test");

I was told "column count does not match value count at row 1".

I could not figure out what's wrong with the syntax. Could someone help me
out. Thanks.


Jul 19 '05 #2
BDR
You can't use that type of syntax when inserting into one field only.

Using a blatant insert into, your input value count MUST match the
number of columns in the table, like this:

insert into test values "this is a test", '0'

This type of insert is not recommended because if your database ever
changes, then all of your programmed query statements will have to
change too.

Better:
insert into test (field1), ("this is a test")

or
insert into test (field1), ("this is test1", "this is test2", "this is
test3")

or

insert into test set field1="this is a test"

jjliu wrote:
i have created the following table:

create table test (field1 varchar(100), id integer unsigned not null
auto_increment, unique (field1), primary key (id));

When i try to insert some values by using the following statement

insert into test values ("this is a test");

I was told "column count does not match value count at row 1".

I could not figure out what's wrong with the syntax. Could someone help me
out. Thanks.


Jul 19 '05 #3
KS
On Mon, 13 Oct 2003 19:54:53 +0000, jjliu wrote:
insert into test values ("this is a test");


If I remember correct you must list the fields in insert clause. So the
correct sql would be
insert into test(field1) values ("this is a test");

-Kari

Jul 19 '05 #4
KS
On Mon, 13 Oct 2003 19:54:53 +0000, jjliu wrote:
insert into test values ("this is a test");


If I remember correct you must list the fields in insert clause. So the
correct sql would be
insert into test(field1) values ("this is a test");

-Kari

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul Lamonby | last post by:
Hi, i want to create a unique serial number to my Db entries. I thought the best way would be to add the auto_increment primary key value to a string, then insert it into a table field...
4
by: Pjotr Wedersteers | last post by:
I have a table with quiz questions. Each question has a unique ID, based on an auto_increment field. Now I've discovered that with deleting rows from the table the deleted ID's are not reissued....
0
by: Miguel Perez | last post by:
Hi everyone: Does anyone know how to reset the auto_increment value of certain table. Any ideas or sugestions Greetings in advance ...
2
by: Ittay Freiman | last post by:
i cannot set auto_increment to start from anything other than 1: mysql> create table test (id int unsigned not null auto_increment primary key); mysql> alter table test auto_increment=2; ...
0
by: Write a Friend | last post by:
When using AUTO_INCREMENT, is there a way to set the starting value. Thanks, Carlos -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: ...
2
by: Nico v. Rossum | last post by:
Hi * How can reset a auto_incremet collumn so it starts from 1 TIA
9
by: Bart Van der Donck | last post by:
Hello, The first column of my table is AUTO_INCREMENT. I fill my table with 5 records with a blanco value in their first field. The first column of my table will then hold the values 1,2,3,4,5...
0
by: Shailesh | last post by:
I made a MyISAM table on mysql 4.0.18 NT with auto_increment column started at 2147483646. The third row I insert fails as expected because the integer range is maxed out. However, if I delete...
1
by: Phil Latio | last post by:
Newbie questions here... Reading the MySQL manual regarding InnoDB databases, can someone confirm that: 1. if the server is rebooted, AUTO_INCREMENT reverts back to 1? 2. what happens if the...
1
by: bcm | last post by:
I am migrating a database to MySQL 5.0. Several tables should have their primary key as an auto_increment integer. The database being copied has records with the primary key beginning with zero...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.