Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
"PostgreSQL Error: relation "table_name" does not exist" When trying to SELECT * FROM "table_name"

I am trying to run a simple script on a simple PostgreSQL database with one table. When I use db.query('SELECT * FROM groups')

I get the error ERROR: relation "groups" does not exist at character 15

I ran the SQL in a Postgresql sandbox and it worked fine when I selected *, so I don't know what the problem here is. Here is the SQL Code

DROP TABLE IF EXISTS groups;

CREATE TABLE groups (
    id serial PRIMARY KEY,
    name varchar(255) NOT NULL,
    birthPlace varchar(255) NOT NULL; );

INSERT INTO groups (name, birthPlace) VALUES
    ( 'Marco', 'Italy' ),
    ( 'Callum', 'Scotland' ),
    ( 'Bob, Ireland' );

And this is the javascript code where I use db.query

const db = require ('../dbConfig')

class Groups {
    constructor(data){
        this.id = data.id
        this.name = data.name
        this.birthPlace = data.birthPlace
    }

        static get all() {
            return new Promise (async (resolve, reject) => {
                try {
                    const groupData = await db.query('SELECT * FROM groups;')
                    const groups = groupData.rows.map(d => new Groups(d))
                    resolve(groups);
                } catch (err) {
                    reject("Error retrieving groups")
                }
            })
        }
   }  
module.exports = Groups;

I have read that this error can arise when quotes or capitals were used when the table is created but I haven't used either anywhere in my code. I hope these code snippets suffice, any help would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!