Querying multiple tables on MySQL

Olek Nowakowski

I have been studying MySQL through a book called 'PHP and MySQL Web Development' and I'm on a chapter that teaches how to query data from multiple tables, I was trying to do it on my own and came up with the following command

mysql> select customers.name from books, customers, orders, orders_items
    -> where books.title = 'Java 2'
    -> and books.isbn = orders_items.isbn
    -> and orders_items.orderid = orders.orderid
    -> and orders.customersid = customers.customerid;

and it returns me the following error

    ERROR 1146 (42S02): Table 'books.orders_items' doesn't exist

but when I try to use the command exactly as it is in the book it works just fine

mysql>select customers.name from customers, orders, order_items, books
    ->where customers.customerid = orders.customerid
    ->and orders.orderid = order_items.orderid
    ->and order_items.isbn = books.isbn
    ->and books.title = 'Java 2';

+-------------+
| name        |
+-------------+
| Julie Smith |
+-------------+

What am I missing here besides the order of the criteria? I have not typed books.orders_items anywhere.

dbmitch

You're using the plural orders_items not the singular from the book order_items

both here

select customers.name from books, customers, orders, orders_items

and in line

and books.isbn = orders_items.isbn

Эта статья взята из Интернета, укажите источник при перепечатке.

Если есть какие-либо нарушения, пожалуйста, свяжитесь с[email protected] Удалить.

Отредактировано в
0

я говорю два предложения

0обзор
Войти в системуУчаствуйте в комментариях

Статьи по теме

TOP список

  1. 1

    Распределение Рэлея Curve_fit на Python

  2. 2

    Merging legends in plotly subplot

  3. 3

    Как я могу нарисовать заполненный прямоугольник в JFreeChart?

  4. 4

    Проблема с window.print в Safari

  5. 5

    Перебирайте несколько столбцов в фрейме данных Panda и находите уникальные значения подсчета

  6. 6

    JetBrains Rider enable-migrations для ASP.NET MVC на Mac

  7. 7

    migrate MongoDB container service - mongodump command not found

  8. 8

    Как создать переменную с использованием класса Color, который включает только выбранные цвета?

  9. 9

    Ошибка XDG0062: не удалось установить «Контент». в режиме навигации MUXC

  10. 10

    Как загрузить ZIP-файл в Nexus с помощью Maven и избежать создания артефакта pom в Nexus?

  11. 11

    QString удалить последние символы

  12. 12

    Symfony 4, Postgres - `Неверное значение параметра client_encoding:« utf8mb4 »` при выполнении команды doctrine

  13. 13

    HTML Body говорит cz-shortcut-listen = "true" с инструментами разработчика Chrome?

  14. 14

    В типе Observable <unknown> отсутствуют следующие свойства из типа Promise <any>.

  15. 15

    Как создать простую анимацию в Xamarin с помощью SkiaSharp

  16. 16

    Установка pip с использованием Python 2.7, установленного в ArcGIS

  17. 17

    Qt - не растягивать виджеты в QVBoxLayout

  18. 18

    How to convert C++/CLI string to const char*

  19. 19

    sbt: Как разрешить зависимости Maven, использующие свойства Maven

  20. 20

    Flutter: Unhandled Exception: FileSystemException: Creation failed, path = 'Directory: '' (OS Error: Read-only file system, errno = 30)

  21. 21

    Как добавить Swagger в веб-API с поддержкой OData, работающий на ASP.NET Core 3.1

популярныйтег

файл