Error Message ORA-00903 in SQL table

5 pts.
Tags:
SQL
SQL Plus
SQL tables
Here is my query:   select guestid, guestfname, guestlname from guest where tourid = 6; It says tourid is an invalid identifier. TourID is a defined attribute in a table called Tour. I'd be grateful for any help.

Software/Hardware used:
SQL Plus

Answer Wiki

Thanks. We'll let you know when a new response is added.

ORA-00903 IS “invalid table name”. Maybe you are receiving an ORA-00904, which means “invalid column name”.

If tourid is a defined attribute in a table called Tour, then you can only use it when querying that table.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Kccrosser
    Carlosdl is correct on both counts. A more basic way of explaining this is that any "attribute" (or field/column, etc.) that is used in the WHERE clause must belong to a table that is listed in the FROM clause. I always like to "alias" my tables in the FROM clause, and then prefix all the column names with the alias. This usually makes the code easier to read and more maintainable and will usually prevent these kinds of missing table names. For example:
    select g.guestid, g.guestfname, g.guestlname
    from guest g
    where .tourid = 6;
    If you cannot identify the alias to use to prefix the "TourID" column, then the table is missing. Assuming that the Tour table contains a TourID and GuestID association, the following may be the (more) correct query:
    select g.guestid, g.guestfname, g.guestlname
    from guest g, TOUR t
    where t.tourid = 6 and g.guestid = t.guestid;
    3,830 pointsBadges:
    report
  • carlosdl
    If you are using Oracle 9i or above, the last query provided by Kccrosser could be rewritten this way too:
    select g.guestid, g.guestfname, g.guestlname
    from guest g JOIN TOUR t
    ON g.guestid = t.guestid
    where t.tourid = 6;
    70,200 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following