4

Mysql query:

How to change the query into postgresql?

INSERT into tablename SET a=10, b=20, c=30
0

2 Answers 2

10

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;
Sign up to request clarification or add additional context in comments.

1 Comment

This solution not working
3

Insert Query:

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

Update Query:

update tablename SET a=10, b=20, c=30 where <conditions...>

3 Comments

i want this query in postgresql
@selva This is the query, you're confused with something that missing in the question and my answer is the way to insert/update data in any DB including PostgreSQL
To add some caution for anyone reading this - if you use that update statement then it will set those values for ALL records in your database. Not just a new record. It's SUPER dangerous

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.