php – Insert into tablename Set Example in postgresql-ThrowExceptions

Exception or error:

Mysql query:

How to change the query into postgresql?

INSERT into tablename SET a=10, b=20, c=30
How to solve:

This is very basic you must do this

Insert Query:

INSERT into tablename(a,b,c) values (10,20,30)

Update Query:

update tablename SET a=10, b=20, c=30

Answer´╝Ü

PostgreSQL does not support syntax INSERT…SET (mysql does).

But another systax can be something you need:

with full fields:

INSERT into tablename
       SELECT 10 AS a, 20 AS b, 30 as c;

with specific fields:

INSERT into tablename (b, c)
       SELECT 20 AS b, 30 as c;

Leave a Reply

Your email address will not be published. Required fields are marked *