-1

It is a simple SELECT statement where i pick data from two tables

SELECT 
    bookingid, customerid, flightid, numseats, 
    passengerid, firstname, surname, passportno,  
    nationality, dobdate
FROM 
    flightbooking, passenger;

I get an error:

ERROR: syntax error at or near "SELECT"
LINE 9: SELECT bookingid, customerid, flightid, numseats, passengeri... ^

I am using PG Admin 4.

Peter Horvath
  • 77
  • 2
  • 2
  • 5

2 Answers2

0

You have two tables so you should use inner join please check this Mysql SELECTIONG FROM TWO TABLES

Community
  • 1
  • 1
0

To troubleshoot, start by changing your query from this:

SELECT bookingid
, customerid
, flightid
, numseats
, passengerid
, firstname
, surname
, passportno
, nationality
, dobdate

FROM flightbooking, passenger;

to this:

SELECT 1 bookingid
/*
, customerid
, flightid
, numseats
, passengerid
, firstname
, surname
, passportno
, nationality
, dobdate
*/

FROM flightbooking join passenger on 1 =2;

If it runs successfully, change select 1 bookingid to select bookingid. If that runs successfully, uncomment 1 field at a time until you get an error. The last field you uncomment would be the cause.

Dan Bracuk
  • 20,699
  • 4
  • 26
  • 43