SQL about database

The database is orders , why can not just put orders in database here but it did work in Mosh’s class ? What is the difference ?

orders is the table
you need to sepcify the database…sql_store ??

You can try

USE sql_store;
FROM orders

or prefix the table name

FROM sql_store.orders

Thanks a lot ! I prefix the table name " sql_store.orders" and it works ! I wonder why “FROM orders” does not work in my side but I watched Mosh’s tutorial he uses “FROM orders”

Not too sure as I am a beginner
but i think if you select the sql_store database in mysql workbench
you can run the query without the prefix

1 Like

I actually answered a similar question earlier this morning.
Both of you got the same message and it is fairly clear about why it happens.

The only missing part is how is simply that you need to specify with what table you’re working on.

USE myDatabase; where myDatabase is of course your database name.

Now @keelo also answered there and I notice you put a sql_ prefix in front of the database name. I did not use MySQL for over a decade but AFAIK the raw name is enough. Is there any new rule / feature / convention related to referring databases in MySQL ?

Could you please tell me what would SHOW DATABASES; output as name to your orders DB?

I presume sql_store is the raw name for the database
If its the same database from Mosh’s MYSQL course the
SHOW DATABASES; output shows


orders is a table on the the sql_store database

This is probably just a convention used by Mosh but I’ll take a look if this is not a thing. I always named my DB simply. Sometimes you use such prefix to specify the facet in the model especially when you have a lot of table. But then it is not specifically sql_ but acc_ for accounting, fin_ for finance, you name it.