Page 1 of 1

MySQL INSERT VALUE STATEMENT inserts 2 rows instead of one

PostPosted: 04. April 2016 15:49
by paranorman
I am doing only SQL, no collaboration with other language, okay? So, don't ask me for no PHP or so.
So, the

INSERT INTO table_name VALUES(value1, value2);

statement adds two rows instead of one! The funny thing is; when I use the UI provided by phpMyAdmin(XAMPP) to add values to the particular table, it works just fine - i.e., it adds a single row; just a single row!
But the insert values statement 'malfunctions.

Any help from gurus here?

Re: MySQL INSERT VALUE STATEMENT inserts 2 rows instead of o

PostPosted: 04. April 2016 19:42
by Altrea
How do you execute the insert statement? MySQL CLI?

Re: MySQL INSERT VALUE STATEMENT inserts 2 rows instead of o

PostPosted: 04. April 2016 21:05
by Nobbie
How do you know about that? Maybe it inserts only one row, but you are shown it twice because of another problem?

Re: MySQL INSERT VALUE STATEMENT inserts 2 rows instead of o

PostPosted: 04. April 2016 21:36
by paranorman
Hey Nobbie.
Funny thing after running the

INSERT .... VALUES( ) command

the program tells me a single roll has been inserted.

When I query the entire table, I see two consecutive rows of the same values (with 2 different PKs of course)!

I run the SQL command from the interface provided by PhpMyAdmin(XAMPP), SQL tab. Altrea

Re: MySQL INSERT VALUE STATEMENT inserts 2 rows instead of o

PostPosted: 05. April 2016 12:55
by Nobbie
As i see now, your INSERT statement lacks a list of columns, maybe therefore MySQL does a multiple row INSERT. As we have no information about your TABLE structure and neither the real INSERT statement, i cannot go deeper into that. Anyway you *should* give a list of columns to the INSERT:

INSERT INTO table_name (col1, col2) VALUES (value1, value2)