Query view different and I don't know why

Hey, I’m new new.

I just finished my first lessons. Mosh’s query view changed between lessons and I can’t figure out how or why he started with USE sql_store; in line 1 but in the following lesson his first command is SELECT…

How did he get the query window to default to the table so that we don’t have to use USE each time?

What should I be looking for to make sure I’m set up correctly.? appreciate your help.

Hi,

I did not take this course so more details could help understand.

USE statement tells which database to… USE… As simple as that.
This is to prevent situations where you’d query the wrong database.

As someone using SQL Server (rather thatn MySQL which seems to be covered by the course), you can easily open a new query windows on the master database instead of the one you intended to use.

It happened to me several times to have queries not working because I was querying master instead of another db.

So it is a good practice to start any script with a USE statement.

Then you can go on with further requests such as SELECT statement.

Cheers.

From what you have said i don’t think your set up is incorrect. As @UniqueNospaceShort said the USE statement just states which database to use for the query. In MySQL workbench you can double click the database you want to use. The database that is bold will be the default database for your query. No need to use the USE statement. When you want to query another database you can just double click that one.

Hope that helps.

Thanks to come up with this option. Of course in a GUI you are given other options.
It didn’t cross my mind it was in MySQL Workbench. When I think SQL it is commands.

Cheers.

1 Like