Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

408
Visualizações
Don't know why the error is always there, inner join issue?
SELECT bookingid, customer.customerid, flightid, numseats, firstname, surname, billingadress, email
FROM flightbooking, leadcustoemr;
INNER JOIN customerid ON flighbooking.customerid = leadcustomer.customerid;

I get a syntax error at or near "SELECT" when i run it in PG Admin 4, where is the problem, i think it is in the inner join, but unsure.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You have a semicolon after leadcustomer (which seems to have a typo itself) - that ends your select statement and the inner join isn't included (in addition, the inner join isn't using the correct table names). Also in the select you are using a column from the customer table (and that table is not joined at all).

I think you are trying to join the flightbooking and leadcustomer tables with the Inner Join and not actually trying to add in a third table. I edited your query here:

SELECT bookingid, flightbooking.customerid, flightid, numseats,
   firstname, surname, billingadress, email
FROM flightbooking
INNER JOIN leadcustomer ON (flightbooking.customerid = leadcustomer.customerid);
over 4 years ago · Santiago Trujillo Relatório

0

The syntax for join has two forms according to this: https://www.postgresql.org/docs/current/static/tutorial-join.html

SELECT *
FROM A, B
WHERE A.id = B.id;

So rewriting the query according to above syntax:

 SELECT bookingid, customer.customerid, flightid, numseats, firstname, 
 surname, billingadress, email
 FROM flightbooking, leadcustomer
 WHERE flightbooking.customerid= leadcustomer.customerid

more standard syntax is:

SELECT *
FROM A
INNER JOIN B
ON A.id = B.id

So rewriting the query results in:

SELECT bookingid, customer.customerid, flightid, numseats, firstname, surname, 
billingadress, email
FROM flightbooking
INNER JOIN  leadcustomer 
ON flighbooking.customerid = leadcustomer.customerid;`

and you could use aliases to make it shorter:

SELECT bookingid, customer.customerid, flightid, numseats, firstname, surname, 
billingadress, email
FROM flightbooking fb
INNER JOIN  leadcustomer  lc
ON fb.customerid = lc.customerid;
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda