SQL Syntax error

Getting this error
[ { message: 'syntax error at or near "SELECT"' } ],
[ { message: 'syntax error at or near "SELECT"' } ],
Here:
const query = `
SELECT
"geo"."city" city,
"jt".title,
"deputy"
FROM
"jobposition" "jp"
LEFT JOIN "geo_location" "geo" ON "geo"."id" = "jp"."geoLocationId"
LEFT JOIN "jp_jobtitles" "jp_jt" ON "jp_jt"."jobpositionId" = "jp".id
LEFT JOIN "jobtitle" "jt" ON "jt".id = "jp_jt"."jobtitleId" AND "deputy" = false
WHERE
"jp"."geoLocationId" IS NOT NULL
AND "jt"."title" IS NOT NULL
GROUP BY
city, jt.title, deputy
ORDER BY
title
OFFSET $1
LIMIT $2;
`;
const query = `
SELECT
"geo"."city" city,
"jt".title,
"deputy"
FROM
"jobposition" "jp"
LEFT JOIN "geo_location" "geo" ON "geo"."id" = "jp"."geoLocationId"
LEFT JOIN "jp_jobtitles" "jp_jt" ON "jp_jt"."jobpositionId" = "jp".id
LEFT JOIN "jobtitle" "jt" ON "jt".id = "jp_jt"."jobtitleId" AND "deputy" = false
WHERE
"jp"."geoLocationId" IS NOT NULL
AND "jt"."title" IS NOT NULL
GROUP BY
city, jt.title, deputy
ORDER BY
title
OFFSET $1
LIMIT $2;
`;
Any idea what I may be doing wrong?
4 Replies
Brendonovich
Brendonovich2y ago
I'm guessing it's the "geo"."city" city. Do you mean "geo"."city" as city?
utdev
utdev2y ago
its postgres forgot to mention same result Like if I run the query in my database ui it works fine
Brendonovich
Brendonovich2y ago
oh well that's odd
CuriouslyCory
CuriouslyCory2y ago
Can you dump the generated query output from your lib? Something like query.getSql()? Might make more sense once you see how the tool has translated your query.
Want results from more Discord servers?
Add your server