Here is my query:
SELECT person_name
FROM travel_card
WHERE id IN
(SELECT travel_card_id
FROM travel_payment
WHERE entry_station_id IN
(SELECT id
FROM station
WHERE name = 'Marina Bay MRT Station'
OR exit_station_id IN
(SELECT id
FROM station
WHERE name = 'Marina Bay MRT Station'))) I
ORDER BY travel_card.person_name
Why do I get this error?
SQL ERROR: from station where name='Marina Bay MRT Station')I)
ERROR at line 4: ORA-00907: missing right parenthesis
Formatting your code is the first step to being able to read it and find bugs, and it's clear there are some bugs.
I think this is what you meant to write:
Notice that
=replacedinfor the station lookups and I un-nested the subqueries.You could (and should) express this using only joins, but I left the structure as similar to your query so the differences were minimised.