Christopher Christopher - 7 months ago 21
SQL Question

ORA 00936 Missing Expression

I have looked through the site and cannot find an answer to my question, many close but none the same. I am trying to select data from two tables and join five. The three which I am not selecting information for are publisher, order_items, and book_order. They are just the tables in the ERD which are in line. I keep on getting ORA 00936: Missing expression on my FROM line. But I have no idea what is causing it. all of the tables are represented accurately, the only thing that is different is the TO_CHAR statement in the SELECT line. I think that may be the problem.

SELECT book_customer.firstname, book_customer.lastname,
TO_CHAR(book_order.orderdate,'MM/DD/YYYY') AS "Order Date",
FROM book_customer, book_order, order_items, books, publisher
WHERE (book_customer.customerid = book_order.customerid)
AND (book_order.orderid = order_items.orderid)
AND (order_items.bookid = books.bookid)
AND (books.pubid = publisher.pubid)
AND (publisher.publishername = 'printing with us');

Answer

You have a redundant comma (,) before your from clause:

SELECT book_customer.firstname, book_customer.lastname, 
TO_CHAR(book_order.orderdate,'MM/DD/YYYY') AS "Order Date" -- Comma removed here
  FROM book_customer, book_order, order_items, books, publisher
    WHERE (book_customer.customerid = book_order.customerid) 
      AND (book_order.orderid = order_items.orderid)
      AND (order_items.bookid = books.bookid)
      AND (books.pubid = publisher.pubid)
      AND (publisher.publishername = 'printing with us');