Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INSERT INTO PostgreSQL

I have got a little problem with SQL. I'm trying to insert 2 values into my table.

that's my query: INSERT INTO tableinfo (table,date) VALUES ('Sell','24 August'); But it doesnt work. I've got something like that:

SQL error:
ERROR:  syntax near "INTO"
LINE 1: SELECT COUNT(*) AS total FROM (INSERT INTO tableinfo (table,...
                                              ^
In statement::
SELECT COUNT(*) AS total FROM (INSERT INTO tableinfo (table,date) VALUES ('Sell','24 August')) AS sub

It's pretty basic so I don't know why it doesnt work :( PostgreSQL 9.2.4

like image 912
Dominik Avatar asked Dec 04 '25 10:12

Dominik


1 Answers

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

like image 169
Roman Pekar Avatar answered Dec 07 '25 04:12

Roman Pekar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!