Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL conditional select throwing error

Tags:

sql

postgresql

I have a PostgreSQL database hosted on Heroku which is throwing me this error that I can't wrap my head around.

CREATE TABLE people (id INTEGER PRIMARY KEY AUTOINCREMENT, age SMALLINT, right_handed BOOLEAN)
SELECT 1 id FROM people WHERE age IN (1) AND right_handed IN (1)

It gives me the error:

Error in query: ERROR: syntax error at or near "IN"

Don't know how to proceed, any help would be greatly appreciated.

like image 618
User Avatar asked May 07 '26 16:05

User


1 Answers

AUTOINCREMENT is not a valid option for CREATE TABLE in Postgres

You can use SERIAL or BIGSERIAL:

ALTER TABLE myTable ADD COLUMN myColumn BIGSERIAL PRIMARY KEY;
like image 51
Robert Long Avatar answered May 10 '26 07:05

Robert Long



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!