为什么我的查询不起作用? (SQL)

时间:2023-01-19 21:47:44

Here is my code

这是我的代码

SELECT flightid,flightdate,numseats,seatnumber,maxcapacity;
FROM flight,flightbooking,seatbooking;

I get and error saying:

我得到并且错误地说:

"ERROR:  syntax error at or near "FROM"
LINE 2: FROM flight,flightbooking,seatbooking;"
        ^

These are my tables

这些是我的表

LeadCustomer (CustomerID, FirstName, Surname, BillingAddress, email) Passenger(PassengerID, FirstName, Surname, PassportNo, Nationality, DoB)

LeadCustomer(CustomerID,FirstName,Surname,BillingAddress,email)乘客(PassengerID,FirstName,Surname,PassportNo,Ethnic,DoB)

Flight (FlightID, FlightDate, Origin, Destination, MaxCapacity, PricePerSeat)

航班(FlightID,FlightDate,Origin,Destination,MaxCapacity,PricePerSeat)

FlightBooking (BookingID, CustomerID, FlightID, NumSeats, Status, BookingTime, TotalCost)

FlightBooking(BookingID,CustomerID,FlightID,NumSeats,Status,BookingTime,TotalCost)

SeatBooking(BookingID, PassengerID, SeatNumber)

SeatBooking(BookingID,PassengerID,SeatNumber)

This is what i am trying to achieve

这就是我想要实现的目标

"Check the availability of seats on all flights by showing the flight ID number, flight date along with the number of booked seats, number of available seats and maximum capacity."

“通过显示航班ID号,航班日期以及预订座位数,可用座位数和最大容量来检查所有航班上座位的可用性。”

The software i am using is PG Admin 4. Thanks.

我使用的软件是PG Admin 4.谢谢。

1 个解决方案

#1


0  

Remove the semicolon at the end of the SELECT line, that should fix it.

删除SELECT行末尾的分号,该分号应该修复它。

Try:

SELECT flightid, flightdate, numseats, seatnumber, maxcapacity
FROM flight, flightbooking, seatbooking;

Of course, I'm not sure this query will be much better. There are no JOIN conditions on these tables or WHERE clauses to filter results.

当然,我不确定这个查询会好得多。这些表上没有JOIN条件,或WHERE子句用于过滤结果。

#1


0  

Remove the semicolon at the end of the SELECT line, that should fix it.

删除SELECT行末尾的分号,该分号应该修复它。

Try:

SELECT flightid, flightdate, numseats, seatnumber, maxcapacity
FROM flight, flightbooking, seatbooking;

Of course, I'm not sure this query will be much better. There are no JOIN conditions on these tables or WHERE clauses to filter results.

当然,我不确定这个查询会好得多。这些表上没有JOIN条件,或WHERE子句用于过滤结果。