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. 4 4665
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.
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.
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 'serial_num'.
$serial_num = "NAME000" . $auto_increment_value;
Is this possible in one function? Or do I have to insert all the other
data first, then get the last inserted id value and then update the
|
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. Makes sense, just thought of that a bit late.
How can I simply re-index or update or how one would call it, the columns
holding the ID numbers ? Is there a ready-made mysql command or do I have to
load all rows in PHP and modify where necessary ?...
|
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
_________________________________________________________________
Únete al mayor servicio mundial de correo electrónico:
|
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;
mysql> insert into test() values();
mysql> select * from test;
+----+
|
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: http://lists.mysql.com/mysql?unsub=mysql@freebsd.csie.nctu.edu.tw
| |
by: Nico v. Rossum |
last post by:
Hi *
How can reset a auto_incremet collumn so it starts from 1
TIA
|
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
(top>down).
Then I erase those 5. Then I add a new record with a blanco first
value. It will get number 6.
|
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 the
topmost row, and then re-insert a row, the topmost value is reused.
This contradicts the documentation.
http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html
"If you delete the row containing the maximum value for an
AUTO_INCREMENT column, the...
|
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 field is specified as or PRIMARY KEY or UNIQUE?
Cheers
Phil
|
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). These keys are foreign keys so it is not desirable to change their values.
Here is what I have been trying:
(1) Truncate table <tablename>;
(2) Alter table <tablename> modify recid integer not null default 0;
(3) <insert rows into table>...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |