Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Trying to execute a standard insert query, but it doesn't work.

INSERT INTO users (vk_id, eu_name, eu_society, eu_notes, eu_want_team)
VALUES ("123123133","Eu name","Eu society","Eu notes","true")

The error I get is the following:

ERROR:  syntax error at or near "INTO" LINE 1: SELECT COUNT(*) AS
 total FROM (INSERT INTO users (vk_id, eu_...

What is causing this error?

share|improve this question
2  
The error message is showing you the error: SELECT COUNT(*) AS total FROM (INSERT ... –  ypercube Aug 21 '13 at 22:36
    
I dont have any clues.... I dont have SELECT COUNT(*) AS total FROM so i dont know where it is taken –  user2705406 Aug 21 '13 at 22:37
2  
Are all those double-quotes okay in postgresql? The documentation I'm looking at just shows single quotes. And does it need a terminating semicolon? –  Hart CO Aug 21 '13 at 22:40
2  
BTW: the strings inside the values need to be in single quotes: VALUES(123123133,'Eu name','Eu society','Eu notes',true) –  wildplasser Aug 21 '13 at 22:40
2  
Well, this could be a bug in phpPgAdmin, I see a report opened in May: Bugs item #3612602, was opened at 2013-05-03 –  ypercube Aug 21 '13 at 23:06

1 Answer 1

I've installed phpPgAdmin to try to reproduce your error. I got it right away when tried to create a test table:

enter image description here

So looks like phpPgAdmin wraping your query into select count(*) as total from (...). I've found that it happens only when checkbox "Paginate results" on query page is set to on (obviously phpPgAdmin trying to count how many rows it will get and then show it page by page). Uncheck it and your query will work fine:

enter image description here

updated 1

Similar question - INSERT INTO PostgreSQL

updated 2

As @akshay mentioned in comments, you also could get similar error running the queries through the command line, see explained situation and answer here - PostgreSQL disable more output

share|improve this answer
    
Great answer, should be checked as correct! –  zavg Dec 6 '13 at 15:14
    
Would never have guessed! You deserve that green checkmark! –  ADTC Dec 18 '13 at 8:17
    
@Roman Pekar I am getting a similar error, but i am not using pgadmin UI. I am running the commands through command line. How can i rectify the error? –  akshay Oct 17 '14 at 6:37
1  
I found the answer here: stackoverflow.com/questions/11180179/… –  akshay Oct 17 '14 at 6:44
1  
thanks @akshay, I've added this information to the answer –  Roman Pekar Oct 17 '14 at 7:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.