MySQL INSERT VALUE STATEMENT inserts 2 rows instead of one

Problems with the Windows version of XAMPP, questions, comments, and anything related.

MySQL INSERT VALUE STATEMENT inserts 2 rows instead of one

Postby paranorman » 04. April 2016 15:49

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?
paranorman
 
Posts: 6
Joined: 27. September 2015 15:47
Operating System: windows10

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

Postby Altrea » 04. April 2016 19:42

How do you execute the insert statement? MySQL CLI?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 8298
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

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

Postby Nobbie » 04. April 2016 21:05

How do you know about that? Maybe it inserts only one row, but you are shown it twice because of another problem?
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04

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

Postby paranorman » 04. April 2016 21:36

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
paranorman
 
Posts: 6
Joined: 27. September 2015 15:47
Operating System: windows10

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

Postby Nobbie » 05. April 2016 12:55

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)
Nobbie
 
Posts: 8779
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 74 guests