述べられた質問はこれでした:
価格が 50.00 ドル以下の中古本のタイトル、著者名、価格は? 結果は、価格の降順で並べ替え、次にタイトルを AZ 順で並べ替える必要があります。
コード:
SELECT book.title, author.LastName, author.firstName, Ownersbook.price
FROM book, author, ownersbook
ON book.isbn = bookauthor.isbn
WHERE Ownersbook.price < 50
ORDER BY Ownersbook.price DESC, book.title ASC;
テーブルを次のようにしたい:
+-------------------------------------------------+------------+-----------+-------+
| title | lastname | firstname | price |
+-------------------------------------------------+------------+-----------+-------+
| ER, SOM, NF, DK/NF, SQL, JDBC, ODBC, and RELVAR | Stratton | Bill | 50.00 |
| My Love's Last Longing | Heartthrob | Danielle | 50.00 |
| How to Keep your Cable Bill Down | Hartpence | Bruce | 45.00 |
| Yes! Networking is for Bills Fans | Lutz | Peter | 40.00 |
| Yes! Networking is for Bills Fans | Phelps | Andrew | 40.00 |
| Yes! Networking is for Bills Fans | Leone | James | 40.00 |
| The Shortest Book in the World | Phelps | Andrew | 35.00 |
| How to Keep your Cellular Bill Down | Hartpence | Bruce | 25.00 |
| My Lost Love's Long Last Lingering | Heartthrob | Danielle | 25.00 |
| From the Shores of Lake Erie to IT | Stratton | Bill | 0.00 |
+-------------------------------------------------+------------+-----------+-------+
10 rows in set (0.00 sec)
ON キーワード ステートメントを削除しようとしましたが、大量のデータが永久に複製されるだけであり、それは望ましくありません。ON キーワードの正しい使い方がわかりません。
エラー:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'ON bo
ok.isbn = bookauthor.isbn
WHERE Ownersbook.price < 50
ORDER BY book.title' at line 2